Hi, I want to display the tag name of my CCSprite
For example
CCSprite* abc = ............;
abc.tag = Sprite1Tag;
Is there any way to use NSString to display the name "Sprite1Tag"
Thanks a lot
Uhm, could you provide more of an explanation of what you want?
The tag on a CSSprite is an integer, and so... it's not very clear what you really want here.
If you just want to print the tag, you can log it: NSLog(@"tag: %d",abc.tag);
Thanks for your quick reply,
I want to use a label control to show the tag name of my sprite in the top left corner when I touch it , your code is only show the tag number, what I want to show here is "Sprite1Tag"
Oh, so then just NSLog(@"Sprite%dTag",abc.tag);
"Sprite1Tag" is just an example, my tag name can be anything, won't follow that format
"Sprite1Tag" is just an example, my tag name can be anything, won't follow that format
Hi, I want to display the tag name of my CCSprite
For example
Code:CCSprite* abc = ............; abc.tag = Sprite1Tag;
Is there any way to use NSString to display the name "Sprite1Tag"
Thanks a lot
Uhm, then you haven't really told me what you want.
Please be very explicit, you're not being so.
Give me real examples of what you want to occur.
----------
And also, remember your tag can only be a number, not a string. So, it can't be "anything"
In this code, Spring1Tag is not an NSString. It's an identifier and it doesn't exist after your code is compiled. So there's nothing you can directly do to print that identifier when your program runs.
However there are other techniques for doing this. One technique is to maintain an array of the sprite name (as NSString objects) and then set the sprite's tag to be the index of the name in that array.
Hmm, so I guess there's no other way can do that directly.
Thanks all