My Game Crashed on android when changing scene

My Game Crashed on android when changing scene
0.0 0


Hi All,

Now I am a big fan of Cocos2d-x.

I have my game running perfectly fine on my PC. but when i port my game on android using cygwin 1.7/Eclipse. the game runs perfectly fine for the first scene (Which is a MainMenuScene) on AVD but as soon as i clicked on start game it crashes showing msg, as.

UNABLE TO GET DATA (BackGroung.png) FROM ASSET. and exits to the home screen on AVD.

I have only two scenes in my game MainMenuScene and GamePlayScene. I tried using BackGround.png in MainMenuScene (First Scene) it loads the BackGround.png in first scene but in second scene it crashes while loading the same sprite…i dont know why…i m surely be doing somthing wrong but i m not able to figure it out so please help me…

Thank you.


How did you load the png in the second scene and the first scene?


i loaded the same way. in both the scene with little difference.

in main menu scene i added as,

CCSprite mainMenuBg = CCSprite::spriteWithFile;
and in GamePlayScene i added as,
gamePlayBg = CCSprite::spriteWithFile(“BackGround.png”);
CC_BREAK_IF(!gamePlayBg );
this~~>addChild(gamePlayBg, 0);


CCP is (480/2, 320/2);


CCP is (480/2, 320/2);


CCP is (480/2, 320/2)


Does BackGround.png in assets?


Yes it gets loaded in MainMenuScene. and i checked in apk as well opening it in WinRar the image is present there…


CCSprite *mainMenuBg = CCSprite::spriteWithFile;
MainMenuScene loads MainMenuBg.png, not BackGround.png.


if i change it to,

CCSprite mainMenuBg = CCSprite::spriteWithFile;
it loads BackGround.png in first scene but it does not loads the same image in second GamePlayScene.
and this problem is coming only on AVD on my PC its running fine.
and my code is like this…
in AppDelegate,
// create a scene. it’s an autorelease object
pScene = MainMenu::constructScene();

// run

and in mainMenu Scene as you click on StartGame i replace scene as,



constructScene() is same like getNode() which calls bool init() where i m adding the image.


I have given all detail of what i’ve done from scratch on this thread. please refer and help me.