In working on some game with Cocos2d-x
I need to change ship sprite dynamically and i used the following code for that
in init method
batchNode = CCSpriteBatchNode::create(“Ship.pvr.ccz”);
sprite = CCSprite::createWithSpriteFrameName;
and in update method
so i want to dynamically change main sprite displayed on screen. It was working fine when when sprite was added directly to the scenere layer
but then i changed it from
and now code with sprite->initWithSpriteFrameName(“ship.png”) doesnt work.
So i guess i do something wrong and not possible to change sprite on the fly from SpriteBatchNode by calling initWithSpriteFrameName function.
I went through Sprite api and couldn’t find any good method for it.
can somebody advice what to use in this situation?
do i need to create list of sprites for each file name and then just dynamically add/remove it from batch node?
or may be it’s better to work directly with scene layer as it worked before?