Hi, I am new to Cocos2d and just test the HelloAction Example. When I add one more sprite to the example, only the last sprite(SpriteB) response to runAction, how can I move two sprites at the same time? Thanks , the code as below:
// Sprite
//
Sprite *spriteA = [Sprite spriteWithFile:@"grossini.png"];
spriteA.position = ccp( 0, 50);
Sprite *spriteB = [Sprite spriteWithFile:@"image230.png"];
spriteB.position = ccp( 300, 100);
// z is the z-order. Greater values means on top of lower values.
// default z value is 0.
// So the sprite will be on top of the label.
[self addChild:spriteA z:1 tag:kTagSpriteMove];
[self addChild:spriteB z:1 tag:kTagSpriteShoot];
// create a RotateBy action.
// "By" means relative. "To" means absolute.
id rotateAction = [RotateBy actionWithDuration:4 angle:180*4];
// create a JumpBy action.
id jumpAction = [JumpBy actionWithDuration:4 position:ccp(size.width,0) height:100 jumps:4];
// spawn is an action that executes 2 or more actions at the same time
id fordward = [Spawn actions:rotateAction, jumpAction, nil];
// almost all actions supports the "reverse" method.
// It will create a new actions that is the reversed action.
id backwards = [fordward reverse];
// Sequence is an action that executes one action after another one
id sequence = [Sequence actions: fordward, backwards, nil];
// Finally, you can repeat an action as many times as you want.
// You can repeat an action forever using the "RepeatForEver" action.
id move = [Repeat actionWithAction:sequence times:2];
id shootobj = [Repeat actionWithAction:sequence times:1];
// Tell the sprite to execute the actions.
// The action will be execute once this Layer appears on the screen (not before).
[spriteA runAction:move];
[spriteB runAction:shootobj];
? Why only sprite B move but not A & B