I am trying to use CCPhysicsSprite by subclassing it and using spritebatching but I’m getting error messages and code is breaking on CCSpriteBatchNode::addChild method.
// check CCSprite is using the same texture id CCAssert(pSprite->getTexture()->getName() == m_pobTextureAtlas->getTexture()->getName(), "CCSprite is not using the same texture id");
Please advise.
Below is my code:
//Create method from my CCPhysicsSprite subclass
SBBall* SBBall::createUsingSpriteFrameName( const char *pszFileName )
{
SBBall *sprite = new SBBall();
if ( sprite && sprite->createWithSpriteFrameName(pszFileName) )
{
sprite->autorelease();
return sprite;
}
CC_SAFE_DELETE(sprite);
return NULL;
}
Code to implement my subclass using spritebatch to load images in the HelloWorldScene.cpp:
................
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("BBMenuSystem/SD/BBMenuSystem.plist");
CCSpriteBatchNode *sbatch = CCSpriteBatchNode::create("BBMenuSystem/SD/BBMenuSystem.pvr.ccz");
this->addChild(sbatch);
SBBall *ball = SBBall::createUsingSpriteFrameName("btnPlay");
sbatch->addChild(ball);
....................