I can initialize or create a new CCSprite object using the following code:
NSString *fileName = [[imagesPath objectAtIndex:i] lastPathComponent];
CCSprite *sprite = [CCSprite spriteWithFile:fileName];
Now, is there anyway to later find out the name of the image file used for the particular CCSprite object?
UPDATE 1:
userData property looks interesting!
No. CCSprite is not retaining the filename.
But like you noticed, you can hang whatever you want off the userData property -- make sure you manage its lifetime properly. Other options are to use subclassing or composition with CCSprite and your other game classes so that you can keep track of additional data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With