Ok, before I start, yes I know the cause. The texture ids do not match. Thing is, I am under the impression that I’m doing the right thing, and this shouldn’t be happen.
In the directory, I have a set of png files:
test1.png
…
test10.png
accompanied by .plist files:
test1.plist
…
test10.plist
+These have been generated by TexturePacker. I’ve gone into the plist files, and for each of them, the metadata~~>textureFileName checks out:+
test1.plist~~>metadata~~>textureFileName = test1.png
…
test10.plist~~>metadata~~>textureFileName = test10.png
At the beginning of the game scene, I preload everything like so:
<pre>
//I don’t have an itoa.
std::stringstream ss;
for
{
std::string strNum;
ss << i;
ss >> strNum;
std::string filepath = “test” + strNum “.png”;
std::string plistpath = “test” strNum +“.plist”;
CCSpriteBatchNode* spriteSheet = CCSpriteBatchNode::create);
//where allSpriteSheets is a CCArray* of SpriteBatchNode, so I can use it later.
allSpriteSheets~~>addObject(spriteSheet);
//where baseLayer is a CCLayer* that is basically the first layer in the game scene.
baseLayer~~>addChild~~>getZOrder
);
CCSpriteFrameCache::sharedSpriteFrameCache~~>addSpriteFramesWithFile );
}
</pre>
later, I attempt to create a sprite using a frame already in the texture used in the CCSpriteBatchNode.
<pre>
CCSprite* sp = new CCSprite;
//I’m purposely setting the frame I want to use here. Every plist file has the exact same naming convention, so it shouldn’t matter which one I use at this point.
std::string initName = “IDL001.png”
//The name is correct, and in fact this frame appears in all plist files, despite the animation length being different.
sp~~>initWithSpriteFrameName);
//the very first SpriteBatchNode I added to the base layer. This exists and is valid, because allSpriteSheets only contain SpriteSheets with the same animation naming convention.
CCSpriteBatchNode* targetLayer = allSpriteSheets~~>objectAtIndex;
//Omitted: setting sprite position
//this line triggers the Assert.
targetLayer~~>addChild(sp);
Did I forget something here?
Thanks in advance.