IMustCode
IMustCode

Reputation: 109

how can I find CCSprites NSString value

Sorry guys, this one is beating it. How can I tell if a CCSprite has a given string value for it's spriteWithSpriteFrameName?

Upvotes: 0

Views: 148

Answers (1)

YvesLeBorg
YvesLeBorg

Reputation: 9079

I think the only choice you have is something like :

CCTexture2D *tex = [[CCTextureCache sharedTextureCache] textureForKey:@"image.png"];
if (tex && tex==sprite.texture) {
    // do your thing ... make certain you understand the
    // key semantics in cocos2d , re texture atlas
}

For myself, whenever getting a new 'cocos2d' version, i systematically add to CCNode a NSString *name property, which i use for various purposes, one of which is similar to what you are trying to do.

Upvotes: 1

Related Questions