English 中文(简体)
页: 1 co2d——对许多 sp使用同样的消毒行动
原标题:iPhone cocos2d - Use the same animation actions for many sprites

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?

问题回答

你们总是能够使用<条码>id采取行动,然后指定一种行动。 和

id myAction = [CCMoveBy actionWithDuration:0.2f position:myPoint];
id mySecondAction = [CCRotateBy actionWithDuration:0.2f angle:myAngle];
id actionSequence = [CCSequence actions: myAction, mySecondAction, nil];

然后通过你所有的间谍活动并附上行动。 如果你有一个阵列,那么方法中的<代码>就会更快。

for (CCSprites mySprites in myArray) {   
     //attach actions to sprites code here

}

我所遵循的一种方法是,我从间谍类中创造出一个等级,并在分类初始阶段分配行动。

例如,我不得不生产10-100件敌方 sp。

Ill 造成来自CC Sprite的一类敌机。

职能

+(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 

当我需要制造这些敌人时,我制造了NNSMuTableArray敌人。

在按照游戏适用各种道路勘察或规则时,我可接触这些阵列的每一物体。

为贫穷的美国人提供服务,但这是我迄今在不问任何人的情况下开展工作的最佳方式;





相关问题
Cocos2d - Shooting Game Problem

everyone, I made a shooting game just like 1942(classic shooting game),but here s the question, FPS drops to 5~6 when the fighter shoot out a straight line of bullet,about 7~8 bullets in the screen,...

AtlasSpriteManager animation

I am using AtlasSpriteManager and AltasSprite to create frame by fram animation with 1 one file. I wanna write something that at first show a simple picture, without any animation and for example when ...

background moves together with image

I have 4 images and a background. I already about to animate the image to move accordingly. But the back ground is not moving. I am not sure how to make the background move accordingly to the movement ...

NSMutable array invalid after objectAtIndex

@implementation Level @synthesize doors, rooms; - (id) init { self = [super init]; if (self != nil) { rooms = [[NSMutableArray alloc] init]; doors = [[NSMutableArray alloc] init]; ...

How to subclass AtlasSpriteManager in Cocos2d?

I need to create some compound sprites that will all move and rotate together. Since it s possible to change the position and rotation of an AtlasSpriteManager I ve been trying to subclass so I can ...

热门标签