Hey, I'm writing game for iPhone, using cocos2d framework.
I have 100 sprites and I want to run on them the same animation. Do I have to create 100 separate actions for each sprite, or can I create one action and use it on every sprite?
Hey, I'm writing game for iPhone, using cocos2d framework.
I have 100 sprites and I want to run on them the same animation. Do I have to create 100 separate actions for each sprite, or can I create one action and use it on every sprite?
One method which i follow is that I create an derived class from sprite class and assign actions in the class initialization .
For example i have to generate 10-100 enemy sprite
i'll make a class enemyActoor.mm derived from CCSprite
their i keep a funtion
+(void)initwithParamters:(CCPoint)spwanPoint frames:(NSString *)plist{
mummyActor *tempInstance =[mummyActor spriteWithWatever suites ur reqirment];
//do all stuff here
//load actions
return tempInstance;
}
//other methods to call actions or access mutators
when i need to generate these enemies i create n NSMuTableArray enemyLoaded and keep all instance in this array ....
when applying various pathfinding algo or rules as per game i access each objects from these array ///
Sorry for poor english but this is the best way i found till now to get work done without asking anyone ;)