cocos2d-x,cocos2d-x-3.0,cocos2d-js , cc.textureCache.addImage blocking UI


cc.textureCache.addImage blocking UI

Question:

Tag: cocos2d-x,cocos2d-x-3.0,cocos2d-js

I want to cache lot of textures in a running scene without blocking it, theoretically cc.textureCache.addImage do caching async if you call it the three arguments. This is not happening.

Code:

rainOfArrows: {
_animFrames:[],
loaded: function(){
  console.log('>>>>>>>>>>>>>>LOAD!')
},
load: function(){
  /* Load all animation arrow sprites in memory & generate animation */
  var str = '';
  for (var i = 0; i < 40; i++) {
    str = 'arrow00' + (i < 10 ? ('0' + i) : i) + '.png';
    cc.textureCache.addImage('res/SkilllsAnimations/arrowRain/'+str, this.loaded, this);
    var spriteFrame = new cc.SpriteFrame(texture, cc.rect(0,0,winsize.width,winsize.height));

    cc.spriteFrameCache.addSpriteFrame(spriteFrame, str);
    this._animFrames.push(cc.spriteFrameCache.getSpriteFrame(str));
  }
},
run: function():{ ----- }
}

The function loaded is executed and string '>>>>>>>>>>>>>>LOAD!' is printed async. But the hole scene freezes until all textures are loaded.

Before v3.0, this was done with addImageAsync and worked fine, now in 3.2 this is merged in addImage but I can not get it working, am I missing something?

Btw, i'm not using textures packed in one img and plist because they're too big.


Answer:

A fix for this has been submitted by pandamicro and will be available in 3.4

Here it is in case you need it before 3.4: https://github.com/pandamicro/cocos2d-js/commit/2a124b5


Related:


Cocos2dx 3.x button sprite [C++]


c++,cocos2d-x,cocos2d-x-3.0
I can't find a way to load the button image from a given .plist file instead of a plain texture. Using Button::create("normal_image.png", "selected_image.png", "disabled_image.png"); or button->loadTextures("normal_image.png", "selected_image.png", "disabled_image.png"); Search for a png and not use the sprite file in the cache. [EDIT] I just want to put a sprite instead...

Is there any wrong in the testcpp code of Cocos2d-X?


c++,cocos2d-x
I have donwload the Cocos2d-X and compile the testcpp. But there is something wrong with it, I locate it and find the following code has something wrong. debugForNormalSprite->drawPoints(positions, 4, 8, Color4F{0.0,1.0,1.0,1.0}); after I check the definition of drawPoints function. I change the braces to parentheses and it works. Is the...

cocos2dx-store on andorid issued with path


android,c++,android-ndk,cocos2d-x-3.0
here is my code, I tried different version of cocos2d-x and the newest cocos2d-x-store, which the program runs well on ios device. The problem is when ever i try to complied to android platfrom, it shows Android NDK: WARNING: APP_PLATFORM android-21 is larger than android:minSdkVersion 9 in ./AndroidManifest.xml make: Entering...

Cocos 2dx iOS 64bit support


ios,xcode,cocos2d-x,arm64
I made a project with cocos2dx and it is working properly. I changed the build settings to make it support 64bit. I soon got errors. So I changed cocos2dx library with one supports 64 bit support. But I cannot find libwebsocket.a support 64bit. Please help me if there is easier...

OpenGL ES 2.0 with static (Fixed Function) pipeline API?


opengl-es,cocos2d-x
I know that OpenGL ES 2.0 standard threw out all the methods that can achieve the same results only keeping one. This is the result why static pipeline is removed from the specification and only dynamic pipeline is present. But it is strange that I use this code and it...

Can I refactor name libcocos2dcpp.so?


android,cocos2d-x,cocos2d-x-3.0,cocos2d-x-2.x
libcocos2dcpp.so is located at path proj.android\libs\armeabi 1) I want to learn to modify how it looks after changing the name "libcocos2dcpp.so" to some "randomname.so" (Intention being, not sure but it might help in protecting my game's source code if people won't know in which thing it is made, I mean...

How to import cocos2dx project in eclipse


android,eclipse,cocos2d-x
I have a problem and want to help from you . I get some Cocos2dx source code I want to publish on the play store I want someone to show me how to add Cocos2dx on eclipse on a Windows machine so I will be able to publish those code...

How to add a Label to a ProgressTimer's Sprite in Cocos2dx?


c++,cocos2d-x,cocos2d-x-3.0
I'm trying to get a ProgressTimer to work with a Sprite that's got a Label as a child. It seems like only the Sprite and none of its children are being used as the sprite for the progress bar. I've got the label created, added it to the sprite. I...

How to build Android NDK cocos2d-x project from within Eclipse?


android,eclipse,android-ndk,cocos2d-x
I set up an Android project that uses cocos2d-x. Now I want to build the project in Eclipse but I get the build error Android NDK: jni/Android.mk: Cannot find module with tag '.' in import path Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined ? Android NDK:...

Cocos2d-x compile android cannot run program


cocos2d-x,cocos2d-android
created new cocos2d-x 3.6 project with cocos console comnand new -l cpp, all variables are set by running setup.py, then when i try to run cocos compile i get compilation errors. log: log.txt Cheked if there are spaces in paths but there isn't, everything is installed....

Cocos2dx soundengine issue on Android Lolipop


android,cocos2d-x,android-5.0-lollipop,cocos2d-x-3.0,cocos2d-x-2.x
I am having an issue with Cocos2dx 2.2.6 on Android 5. After playing my game for a little while it starts to severely lag. This does not happen with Android 4. After doing some research many people have said it is a problem with Android 5 working with Cocos2dx's Audio...

Cocos2d-x: How can I draw a resizing rectangle?


c++,cocos2d-x-3.0
I'm working on a project with Cocos2d-x 3.4 (wonderful framework BTW :) ). I was wondering how I can draw a simple translucence selection, the same selection you can see on Windows ? http://cdn.maximumpcguides.com/windows-7/wp-content/uploads/2010/11/use-translucent-select-rectangle-2.png I tried to use the DrawNode class, but failed to achieve this :'( I hope that...

make: *** [obj/local/armeabi/objs/cocos2dcpp_shared/hellocpp/main.o] Error 1


android,eclipse,android-ndk,cocos2d-x,cocos2d-x-3.0
I am trying to port cocos2dx game on android plat from. When I build the project the following message appears Build of configuration Release for project test_pro python /Users/itronix/Documents/Rizwan_Projects/cocos2dx_3_2/workspace/test_pro/proj.android/build_native.py -b release all Android NDK: WARNING: APP_PLATFORM android-19 is larger than android:minSdkVersion 9 in ./AndroidManifest.xml Android NDK: WARNING:jni/../../cocos2d/cocos/./Android.mk:cocos2dx_static: LOCAL_LDLIBS is always...

Migrate Cocos2d-x project from Mac to Ubuntu


c++,osx,ubuntu,cocos2d-x
I'm developing a game on C++ using Cocos2d-x v3.5. I use latest Xcode and have no problems with make & run. But my friend who wishes help me can't run my project on his Ubuntu. We guess something is wrong with cocos2d make-files (we've found 2 named CMakeLists.txt ). Are...

Cocos2dx 3.4 - manipulating user input


text,input,user,field,cocos2d-x
I am working on a breakout-type game using Cocos2dx, and I need some help, as I am a complete novice. Currently I need to make a highscore table. After the game is finished, I'd like to display a page, where player types his username into text field. The problem is...

Getting error: Execution failed for task : myApp:compileDebugNdk'


android,android-studio,android-ndk,cocos2d-x,cocos2d-android
Hi I am trying to run an app created with Cocos2d-x 2.5 with Android Studio but I keep getting this error when running the project: :myApp:compileDebugNdk AGPBI: {"kind":"ERROR","text":"*** Android NDK: Aborting... . Stop.","sourcePath":"/mypath/ndk/android-ndk-r10d/build/core/add-application.mk","position":{"startLine":199},"original":""} FAILED Execution failed for task ':myApp:compileDebugNdk'. Building works ok. I have Android Studio 1.1.0 and a Mac...

Move a sprite along a particular direction cocos2d


python,cocos2d-x,cocos2d-python
I want to move a sprite along a particular direction until next keypress in cocos2d. The code to handle a keypress is as follows, def on_key_press(self, symbol, modifiers): if symbol == key.LEFT: DIRECTION="left" before=self.player.position height=self.player.position[1] width=self.player.position[0]-1 self.player.position=width,height self.player.rotation=-90 if(height>=600 or height<=0): print ("you lose) if(width>=800 or width<=0): print ("you lose)...

libcocos2dx resource error: resource directory does not exist


android,eclipse,box2d,cocos2d-x-3.0
Yesterday I tried to add Box2D to my cocos2dx project. One error appeared and I haven't been able to solve it. The error: [2015-03-06 10:41:41 - libcocos2dx] ERROR: resource directory 'C:\devAndroid\cocos2d-x-3.2\cocos2d-x-3.2\SuperCars\cocos2d\cocos\platform\android\java\res' does not exist The point is that the package explorer itself only shows a red exclamation in the project...

Create Dynamic Body using cocos 2d js and Chipmunk


javascript,cocos2d-x,game-physics,chipmunk,cocos2d-js
I am fairly new to cocos 2d and chipmunk. So far i have managed to create a static object and add collision handler to it. But i want to create a dynamic.``this.space = space; this.sprite = new cc.PhysicsSprite("#rock.png"); var body = new cp.StaticBody(); body.setPos(pos); this.sprite.setBody(body); this.shape = new cp.BoxShape(body, this.sprite.getContentSize().width,...

Action for changing the color of layer?


cocos2d-x
My game consists of a single scene which is a LayerColor. However, as I transition between "levels", I would like to change the background color via a smooth transition. For example, if the rgb values of level 1 is (100,50,70) , and the rgb values of level 2 is (200,30,123)....

(SOLVED) Java build path error in cocos2dx 3.6


java,ant,path,android-ndk,cocos2d-x
I migrated from cocos2dx 3.1.1 to 3.6 yesterday. And when I make new project and build in eclipse, I get the following error: could not open 'C:\Program Files (x86)\Java\jre7\lib\i386\jvm.cfg This isn't simple problem. I have quadraple checked environment variables. Although all of my environ variable is on E:\, build_native is...

fontconfig/fontconfig.h not found in Codeblocks


cocos2d-x,codeblocks
I am trying to build Cocos2d-x project in Codeblocks IDE in Ubuntu 14. I got fontconfig/fontconfig.h not found error during compiling. I'm stuck here. How can I solve this?

Cocos2d-x Change MenuItemImage on cursor focus


android,c++,cocos2d-x
Using Cocos2d-x 3.4 on Windows7. How to change "MenuItemImage" image on mouse cursor focus? (on Windows) ** I want "mouse over(hover) effect" to MenuItemImage. ** I know, how to create "not touch" or "clicking" button. auto button = MenuItemImage::create( "button_normal.png", "button_pressed.png", [](Ref* ref){ // do anything if clicking }); auto...

Cocos2dx Android and IOS build


cocos2d-iphone,cocos2d-x,cocos2d-x-3.0
I have downloaded latest version of cocos2d-x from this link. And worked on Visual Studio Environment and finished. Now I am going to build it to Android and IOS for extra processes. What can I do?...

Google Play Game Services C++ integration


android,c++,cocos2d-x
Sorry For My Bad English I am new in cocos2d-x, i am trying to develop an application uses the google game services, I installed my environment with cocos2d-x 3.4 and NDKr10c I followed the steps of this solution but I have a problem in the InitServices method I have two...

How to make TMXTiledMap responsive?


android,opengl-es,cocos2d-x,resolution,tiled
My game is a 2D car-based one, with a straight infinite map where I've finally been able to add some random obstacles. There are only 3 positions the car can be at, and everything is working fine. The point is that I've recently noticed that it is not responsive, and...

How to retrieve the visible texture from a png image in cocos2d-x


cocos2d-x,cocos2d-x-3.0
I am making a question answer game in which the answer images are made as sprites from png images. The answer image is like this: I am making rect on the image like this: Rect rect = Rect(answerSprites.at(i)->getBoundingBox().origin.x, answerSprites.at(i)->getBoundingBox().origin.y, answerSprites.at(i)->getBoundingBox().size.width, answerSprites.at(i)->getBoundingBox().size.height); Then i am detecting touch on the rect as...

cocos2d-x use create() method in update method


cocos2d-x
i use cocos2d-x for my game. i have some question about cocos2d-x create method. i always use create() method to create new Animation , Animate , RepeatForever Object when the game character needs to change the animation in Update Method but i think this is not good because if i...

In CoCos2dx how to use admob and google play sevices together


admob,cocos2d-x,google-play-services
I was trying to integrate both Google pay services and Admob together in my Android game developing in Cocos2dx.But I'm getting this error Unable to execute dex: Multiple dex files define Lcom/google/ads/AdRequest$ErrorCode; Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/google/ads/AdRequest$ErrorCode; Please help me to...

How to implement Android in-app purchase in Cocos2d-x v3.5


android,c++,in-app-purchase,cocos2d-x,android-billing
I'm using cocos2d-x v3.5 and I want to add In-app purchase feature to my game. I gave a try for built-in plugin of cocos2d-x but had no luck (http://www.cocos2d-x.org/wiki/Plugin-X_Integration_Guide_for_Android I read this guide). Then I try to implement Soomla framework, I follow the instruction from here https://github.com/soomla/cocos2dx-store but can't compile...

cocos2dx 3.3 animation implementation


c++,cocos2d-x,cocos2d-x-3.0,cocos2d-android,cocos2d-js
I am new in cocos2dx development.I almost learn all basic level of cocos2dx (version 3.3) in android using cpp language. I showing that there are lots of update over cocos2dx.org. In android I am currently developing the tetris game using cocos2dx version 3.3, I want to know what is the...

Cocos2d C++ Identify CCSprites with UserData?


c++,windows,cocos2d-x,ccsprite,userdata
I am stuck in my Game cause I have to much Sprites in CCArrays. I identify the function of the Sprite on it's Tags, but it's not working, cause I only can use Ints as Tag. So I decided to make UserData like this: int* nums = new int(2); background->setUserData((void*)nums);...

EXE_BAD_BADACCESS trying to access GKMatch?


cocos2d-x,real-time,game-center,invite,gkmatchmaker
The Problem In Brief Trying to play with a friend in real-time using gamecenter causes a crash during gameplay Project Details I am using gamecenter with cocos2dx I am using the SANDBOX mode: Both accounts being tested are in sandbox mode 2 Ipads are used for testing (IOS 8.3) I...

Why cocos2d-x schedule changed the member object?


c++,cocos2d-x
I have these two classes in cocos2d-x project: class A : public Layer { ... B * b; void callAddNumber(float dt); } A::A() { b = B::create(); } void A::callAddNumber(float dt) { b->addNumber(); } class B : public Node { ... int number; B(); void addNumber(); } B::B() { number...

Include msgpack in cocos2d-x 3


cocos2d-x-3.0,msgpack
I want to use msgpack with cocos2d-x 3. I add include_directories(msgpack/include) in cocos2d/cocos/CMakeLists.txt. but not found msgpack.hpp. How I can include and compile msgpack with cocos2d?

Round decimal for a float number


c++,visual-c++,integer,cocos2d-x-3.0
in VC++ I have a float number say 1.32544354353 i.e float num=1.32544354353; I want only first 1 digit after point. i.e 1.3 (not 1.300000000). How can I get this? Please help me... If their is a solution in Cocos2dx thats better(I want this in my cocos2d-x game)

CCParallaxNode moves on and convertToWorldSpace give wrong values cocos2d iPhone


ios,objective-c,iphone,cocos2d-iphone,cocos2d-x
I have used the code below for collision detection. but as CCParallaxNode moves on in infinite scrolling. my positions goes wrong. i have tries every possible solution till yet. but everything gives me wrong values in parallax. for (CCSprite *sp in PathsArray) { if (sp.tag==500) { CGPoint sprect=[self convertToWorldSpace:sp.position]; CGRect...

Use Spine in Cocos2dx


cocos2d-x-3.0
In cocos2dx, I use the class skeletonAnimation to create the skeleton animation which uses the resources exported by spine. We know the class skeletonAnimation is the subclass of node not is sprite. How to do to make the skeleton animation flip the node as it like to use the method...

How to get the width of a Node?


c++,cocos2d-x,cocos2d-x-3.0
The idea is that I have a parent Node as a container with a bunch of Sprites as children, and that I can have the Node's width include the width of the children, since I'm assuming the size would encompass its children, but it doesn't look like it. I've got...

Cocos2d-x. How to add action on the sprite after the previous one was finished


action,cocos2d-x,sequence
I add action on the sprite. auto moveBy = MoveBy::create(2, Vec2(moveX, moveY)); _Spr1->runAction(moveBy); I want to add another action on touch, but I want that the second one started after the first one is finished. And if I tap two times before first action stops, I want to create sequence...

Handling touches on child layer Cocos2d-x


c++,ios,cocos2d-x,event-listeners
I've added a layer as a child in a scene. I want when I touch any sprite on this child layer , touch does not go to parent layer. I've written following code for register touch events but touches still going to parent layer, instead of returning back from it....