there's no pkm after buildbing with etc1
Question for Html5 Gamedev
@Andres_IC wrote:
For those who actually do money with html5 games, how do you make a profitable business with html5 games?
Posts: 1
Participants: 1
Plugin Files not allowed to export objects
@Orlan wrote:
Hi all,
In my project I need some npm modules, including babelify and babel-preset-es2015.
Problem is that babel-preset-es2015 exports objects, which is obviously not allowed by Cocos Creator, according to my build error:Build Failed: Compile error: Plugin/Preset files are not allowed to export objects, only functions. In D:\Dokumente\Cocos2D\Whammychat\node_modules\babel-preset-es2015\lib\index.js while parsing file: D:\Dokumente\Cocos2D\Whammychat\node_modules\tmi.js\index.js
at Readable. (D:\Programme\Cocos211\resources\app.asar\editor\page\build\compile-worker.js:1:3617)
at emitOne (events.js:96:13)
at Readable.emit (events.js:191:7)
at Labeled. (D:\Programme\Cocos211\resources\app.asar\node_modules\read-only-stream\index.js:28:44)
at emitOne (events.js:96:13)
at Labeled.emit (events.js:191:7)
at Labeled. (D:\Programme\Cocos211\resources\app.asar\node_modules\stream-splicer\index.js:130:18)
at emitOne (events.js:96:13)
at Labeled.emit (events.js:191:7)
at Deps. (D:\Programme\Cocos211\resources\app.asar\node_modules\stream-splicer\index.js:130:18)
at r.waterfall.r (D:\Programme\Cocos211\resources\app.asar\editor\lib\builder\index.js:1:3393)
at D:\Programme\Cocos211\resources\app.asar\node_modules\async\lib\async.js:52:16
at D:\Programme\Cocos211\resources\app.asar\node_modules\async\lib\async.js:696:30
at D:\Programme\Cocos211\resources\app.asar\node_modules\async\lib\async.js:167:37
at D:\Programme\Cocos211\resources\app.asar\node_modules\async\lib\async.js:1209:30
at Gulp.doneCallback (D:\Programme\Cocos211\resources\app.asar\editor\core\gulp-build.js:1:28089)
at Gulp.Orchestrator.stop (D:\Programme\Cocos211\resources\app.asar\node_modules\orchestrator\index.js:150:9)
at C (D:\Programme\Cocos211\resources\app.asar\editor\core\gulp-build.js:1:6396)
at D:\Programme\Cocos211\resources\app.asar\editor\core\gulp-build.js:1:8465Why are plugins not allowed to export objects? Is there any workaround or option to allow them to export objects?
Thanks in advance
Posts: 1
Participants: 1
Visible node inside camera
@C_Stefano wrote:
Hi, a new noob question
Is there a way to know if a node (a child about other node) is inside a camera? (then it visible)Many thanks for help!
Stefano
Posts: 1
Participants: 1
SPINE asset error: "Slot not found: name"
@minhttbravestar wrote:
Hi guys, i’m having trouble when trying to import SPINE data (atlas + json + png file) into Cocos Creator (v1.9.3). The message “Error: Slot not found: name” keeps showing up like the picture below.
I’ve tried many options when exporting animation skeleton from SPINE (the latest version), none of which worked.
Posts: 1
Participants: 1
a new lua binding layer for cocos2dx base on lua gc
@codetypes wrote:
Recently, i design a new lua binding layer for cocos2dx, and it controls life cycle of c++ object by lua gc.
Feature:
- manage c++ object by lua gc, it more friendly to developer.
- the exported lua binding code is more simple and efficient.
- support more lambda function binding(schedule, scheduleOnce, …).
- support more api for spine, fairygui, dragonbose.
- the binding layer is more simple then tolua++.
The below code it is safety for cocos-lua, and not safety for cocos2d-x official lua binding.
local sprite = cc.Sprite:create() local funtion update(dt) sprite:setFlippedY(true) end
see more detail: https://github.com/zhongfq/cocos-lua
Posts: 1
Participants: 1
a new lua binding layer for cocos2dx base on lua gc
@codetypes wrote:
Recently, i design a new lua binding layer for cocos2dx, and it controls life cycle of c++ object by lua gc.
Feature:
- manage c++ object by lua gc, it more friendly to developer.
- the exported lua binding code is more simple and efficient.
- support more lambda function binding(schedule, scheduleOnce, …).
- support more api for spine, fairygui, dragonbose.
- the binding layer is more simple then tolua++.
The below code it is safety for cocos-lua, and not safety for cocos2d-x official lua binding.
local sprite = cc.Sprite:create() local funtion update(dt) sprite:setFlippedY(true) end
see more detail: https://github.com/zhongfq/cocos-lua
Posts: 1
Participants: 1
Screen Resize issue in EditBox
@manojkumarrai wrote:
@slackmoehrle, @Big_Bear I have resizing issue with windows and MAC build if we resize the gameplay, the editBox text did not resize and half visible. The text inside editBox did not resize. can you please help.
Posts: 3
Participants: 2
How to play animation using Button event in cocos creator
@kiraxeno09 wrote:
I need to make an urgent move when on click event I need to set an animation in typescript urgent help
Posts: 1
Participants: 1
Cocos Creator 2019 Roadmap (updated August 2019)
@slackmoehrle wrote:
The whole team is working hard to bring you amazing versions of Cocos Creator. I’ve recently seen upcoming products and I was blown away. The future looks amazing.
As part of this we revived the public Trello roadmap! It is not easy for developers to see what is planned for future versions and approximately when to expect these versions.
Please take a look: https://trello.com/b/JWVRRxMG
Posts: 3
Participants: 2
Cocos Creator accounts for over 70% of the best WeChat mini games
@CocosMarketing wrote:
There was a meeting with Tencent this past week about WeChat mini games that we think you’ll love to hear. When it comes to mini games, we have over 70% of the top games. It’s fantastic, and we have a few examples of what games people are playing today.
Cocos Creator accounts for over 70% of WeChat’s top mini games
Posts: 1
Participants: 1
Way to launch keyboard without visual textbox
@ebouchard wrote:
Is there a way to achieve it? I’ve seen other threads (a few years old) with no answer. I’ve looked at textfield and EditBox, but they both have a visual box on the screen associated with it. All I want is be able to launch a virtual keyboard, from wherever I want and then receive callback with the text so I can manage the visual aspect of the in-game text.
Thanks
Posts: 2
Participants: 1
JNIHelper isn't aware of java class
@Apollo18 wrote:
I’m trying to call a java function from a C++ class. Here’s what I’ve done:
1.) Created a class in Android Studio called “AdHelper” in the app/src/com/myCompany folder. It has a public static function “test” which in theory should log the message “Please let me just have this one success today.”
package com.myCompany; public class AdHelper { public static void test() { System.out.println("Please let me just have this one success today."); } }
2.) In my C++ class I have the following code:
JniMethodInfo t; if (JniHelper::getStaticMethodInfo(t, "AdHelper", "test", "()V")) { t.env->CallStaticVoidMethod(t.classID, t.methodID); t.env->DeleteLocalRef(t.classID); }
3.) In the progaurd-rules.pro file I added:
-keep public class com.myCompany.** (*;}
And I get the error:
E/JniHelper: Classloader failed to find class of AdHelper
TLDR; What do I need to do to allow JniHelper to find my java class?
Posts: 1
Participants: 1
Editbox with password-input flag not working in creator
@rsamrry wrote:
hi,
I am using editbox with input flag set to password and the input mode set to single line. when I run it in the editor it works more or less ok but it omits the last character entered and registers only the characters till before the last one.
on my android device, it doesn’t register even a single character and I can’t even get rid of the placeholder text.
editbox_password_test.zip (1.2 MB)
I haven’t tried it on iOS yet, and the version of cocos creator I am using is 2.1.2.
thanks!
Posts: 1
Participants: 1
Cocos is starting a new video series! Check out our first episode
@CocosMarketing wrote:
Cocos is starting a new video series! We are looking at developers building their games with Cocos Creator or Cocos2d-x and asking them questions about game development and the business behind the game industry. Our first video is with Martin of Super Mega Space Game.
If you would like to be a part of our interview series, contact us here with your game so we can showcase it to the world.
Posts: 2
Participants: 1
Tutorial: Scrollview Optimization in Cocos Creator
@slackmoehrle wrote:
Cocos Creator ScrollView Performance Optimization
Note: This article is based on Cocos Creator 2.1.2 version
Note: You can reference to this demo project
Introduction and why are there performance problems
The ScrollView component of Cocos Creator is a common component in game development. It is often used in game interfaces, like ranking interface, task list, package system and other modules. However, it can suffer from performance issues. When needing to display many items, performance can be a blocker because Cocos Creator only implements the most basic features of scrolling. Developers to do some optimization depending on their usage situation.
ScrollView can suffer from these performance issues:
- Higher quantities of
DrawCall
and lower rendering performance- Too many nodes in a
ScrollView
, can cause higher performance overhead when invoking theEnable
andDisable
functions when we hide or show the interfaceFor example, this interface suffers from performance issues:
The
ScrollView
component in this scene has 20 cells,the totalDrawCall
has reached 790. A single cell has about 50 child-nodes, and in total about 1000Node
objects in this interface. Can you see why performance is an issue?General optimizations
First, let’s do some general optimizations to help gain some performance.
We need to merge the rendering batches to reduce the number of
DrawCalls
, so that we can improve the rendering performance, there are two different way to achieve it:
Plan A: Packaging textures in an atlas texture using Auto-atlas or TexturePacker
This allows multiple
Sprite
objects rendered with the same atlas texture, so that we can merge those rendering batches and optimize the number ofDrawCalls
and the CPU performance.
Using Auto-atlas, you can reference this document to get more information on Auto-atlas AssetsLet’s see the result of using Auto-atlas:
Notice the number of
DrawCalls
had dropped to 556 which was lower than before, it is also only 20 cells.Plan B: using the dynamicAtlas feature, you can add the following code to your
main.js
file to open this feature:
cc.macro.CLEANUP_IMAGE_CACHE = false; cc.dynamicAtlasManager.enabled = true;
After opening, Cocos Creator, will help us merge textures into a atlas texture automatically and dynamically when the project is running. This shows us a result, the number of
DrawCalls
had dropped.If you are debugging on Google’s Chrome browser, you can use a plug-in named spector.js to debug the number of
DrawCalls
and can see how each DrawCall handles textures. For native development, we can use theGPU analysis
inXCode
Handling the
Label
objects。
If we use Auto-atlas or TexturePacker to handle textures, we can
BMFont
objects withLabel
objects instead ofSystemFont
objects, so that we can package our font image with other textures into an atlas texture.You can see the
DrawCalls
has been further reduced, and is now 330.If we used dynamicAtlas feature, then we can use
SystemFont
objects withLabel
objects, and can make sure theLabel
objects CacheModde property has changed toBITMAP
mode.In BITMAP mode, the
Label
object’s texture will be handled as aSprite
texture, and flow into dynamicAtlas. Then the texture betweenLabel
andSprite
could be merged. The result:It should be noted that the dynamicAtlas feature will bring more CPU calculations and overhead due to rendering the dynamicAtlas texture.
Only displaying what we need
- The
Node
objects that are off screen (outside what we can see) do not need to be rendered. Through the calculation of the cell’s position, we can know what cell should be visible and what cell should be hidden. We can use this to set theopacity
property ofNode
objects that do not need to be displayed to 0, then we can reduce the cost of GPU cycles, and therefore reduce the number ofDrawCalls
. This is some example code:update (dt) { var viewRect = cc.rect(- this.view.width / 2, - this.content.y - this.view.height, this.view.width, this.view.height); for (let i = 0; i < this.content.children.length; i++) { const node = this.content.children[i]; if (viewRect.intersects(node.getBoundingBox())) { node.opacity = 255; } else { node.opacity = 0; } } }
The logic is in the
update
function, you can also put this code in the scrolling callback ofScrollView
, then we do not need to calculate every frame, this is then only calculated when we need to reduce the cost of CPU.We can see the number of
DrawCalls
has dropped to 68 based on using dynamicAtlas.Try to implement your interface without using
mask
components, or usemask
components as minimal as possible.
Because the
mask
component needs to add render commands to change the GL state before and after stencil and content, so themask
component will break the merge and can add additionalDrawCalls
.When we need to display some special display, Like icon with rounded corners, try to implement it without
mask
component if possible. For example, ask your artist to provide you rounded resources.Currently,
mask
components,spine
components, anddragonBone
components will interrupt the batching process, we should avoid them and instead optimize your scene graph.In the demo project, each following icon has a child node which used
mask
component:
Disabling the
mask
component results in the following:Finally, just 18
DrawCalls
!
ScrollView
has amask
component which is used for culling the display and we can not avoid this operation.Reuse those cells and reduce the number of
Node
objects.
We do a lot of optimization on the number of
DrawCalls
already, but the actual number ofNode
objects is still very large. When the interface is shown or hidden, a large number ofNode
objects means a large cost of invokingEnable
andDisable
. We can reuse those cells and update the location and display to reduce the number ofNode
objects.You can reference the
ListView
case in Cocos Creator examples. It works as follows:You can see the detailed code in the ScrollView3 scene of the demo project.
Conclusion
Finally result as follows:
We use only 7 cell nodes to achieve a list of 20 cells, the number of
DrawCalls
is down to 18, and the actual number of nodes used is about 300, much less than the 1000 we started out with. If you take into account some of these commonScrollView
optimizations it can greatly improve the performance of your game.Thank you for reading!
Posts: 2
Participants: 1
Why AudioEngine audioState is ERROR?
@JohnJose wrote:
Hi,
i am using a slider in audio. when i change the slider percent, some times it play audio, other time audioEngine returning ERROR as audioState.
anyone Please help me to solve
Posts: 1
Participants: 1
How to get widget (Button) "world" size?
@serpri wrote:
Hello.
How to get widget (Button) “world” size (after all scale, anchor and other transformations I’ve done to it)?
Like I get widget getWorldPosition();
Thank you.
Posts: 2
Participants: 1
Problem About Spritesheet Animation
@Refetizm wrote:
Hi everyone,
I wrote that code for spritesheet animation. But it gives error about pushBack() function. Where is the problem about this code ?
SpriteBatchNode* spriteBatchNode = SpriteBatchNode::create("Character.png"); SpriteFrameCache* frameCache = SpriteFrameCache::getInstance(); frameCache->addSpriteFramesWithFile("Character.plist"); auto sprite = Sprite::createWithSpriteFrameName("wlk1.png"); spriteBatchNode->addChild(sprite); spriteBatchNode->setScale(2.0); //spriteBatchNode->setAnchorPoint(Vec2(0.0, 0.0)); spriteBatchNode->setPosition(Point(visibleSize.width / 2 + origin.x, 100)); this->addChild(spriteBatchNode); Vector<SpriteFrame*>frames; for (int i = 1; i <= 8; i++) { std::string frameName = cocos2d::StringUtils::format("wlk%d.png", i); SpriteFrame* frame = frameCache->getSpriteFrameByName(frameName.c_str()); frames.pushBack(frame); } Animation* animation = Animation::createWithSpriteFrames(frames, 0.1f); animation->setLoops(-1); auto animate = Animate::create(animation); sprite->runAction(animate);
Posts: 2
Participants: 2
I18N not working when release
@micheal_kis0909 wrote:
Hello guys
I followed the guide about i18n in Cocos Creator manual (installing extension, create
en.js
,zh.js
…) and then it worked like a charm IN DEVELOPMENT MODE.However, when I build the project for the Web Desktop platform, those localized labels only show the keys, not the values. I guessed that those file
en.js
,zh.js
are not loaded into thewindow
object.Have anyone had a completely working example regarding i18n? Did I miss something regarding i18n?
(For now, I only need to internationalize the text of labels)
Thank you.
Posts: 1
Participants: 1