Hi!
is there any way to create an sprite using createWithSpriteFrameName method and put it into a SpriteBachNode (CCSpriteBatchNode)?
I have this code and I get and error: CCSprite is not using the same texture id
BatchNode = CCSpriteBatchNode::create(“spriteMenu.pvr”);
this~~>addChild;
frameCache = CCSpriteFrameCache::sharedSpriteFrameCache;
frameCache~~>addSpriteFramesWithFile(“spriteMenu.plist”);
sRed = CCSprite::createWithSpriteFrameName(“red_b.png”);
BatchNode->addChild(sRed,10);
Thank you!
Hi Roger,
I finally got it working… In Cocos2DX 2.x we should try to use the “create” method for all the static initializers. I hope it helps!
// Add the frame coordinates to the cache
CCSpriteFrameCache::sharedSpriteFrameCache()>addSpriteFramesWithFile;
// Init sprite batch
CCSpriteBatchNode *spriteBatch = CCSpriteBatchNode::create;
this>addChild(spriteBatch);
// Create menu
CCSprite playOn = CCSprite::createWithSpriteFrameName;
CCSpriteplayOff = CCSprite::createWithSpriteFrameName(“play_off.png”);
CCMenuItemSprite **menuPlayItem =
CCMenuItemSprite::create);
CCMenu**menu = CCMenu::create(menuPlayItem, NULL);
this->addChild(menu);