am I able to retrieve a batched Sprite’s frame name that it was created with? Sprite* sprite = Sprite::createWithFrameName("bullet.png");
later… sprite->getFrameName(); // "bullet.png"
I’ve looked at Sprite/SpriteFrame, and know of the SpriteFrame Sprite::displayFrame() method, but I don’t see anyway to actually get the original frame name (e.g. “bullet.png” in the above example)
in the file CCSpriteFrame there is protected member called :
_textureFilename
that keeps the file name , not sure why its not exposed i also need to get the name of the texture.
what i did is to extend the Sprite class and keep the file name as private member
In cocos2dx 3.16, I check against the cache. I think there’d be a better way, but I can’t find it if there is:
if (sprite->getSpriteFrame() != SpriteFrameCache::getInstance()->getSpriteFrameByName(new_sprite_path)) {
sprite->setSpriteFrame(new_sprite_path);
}
It’s not quite getting the sprite frame name (and the textureFilename lists the spritesheet, pretty sure) but it solves the problem I was dealing with.