I use NSMutableArray to store my sprites.
if I two sprite classes CCSprite & CCMySprite a can add it to NSMutableArray but how can I get them from the array?
Different sprite in ONE NSMutableArray
(4 posts) (3 voices)-
Posted 1 year ago #
-
Dont know if is this you are looking for. But use objectAtIndex.
CCSprite *mysprite = [CCSprite spriteWithFile:[myArray objectAtIndex:0]]Posted 1 year ago # -
I know about objectAtIndex method but your example works if array contains sprites of ONE class inside. How can I get both CCSprite & CCMySprite from array?
Posted 1 year ago # -
A quick and dirty hack is to pull out the object and run [object respondsToSelector: ] with the name of a method you created for your CCMySprite that CCSprite does not have.. then you can know to cast your object to your CCMySprite Class.
You can also use isKindOfClass or isMemberOfClass .. I don't remember which you'd want off the top of my head though.
-Mark
Posted 1 year ago #
Reply
You must log in to post.