我正在使用cocos2d并且我有一个for循环来创建一堆精灵,我正在对forloop中的每个精灵运行一个动作,但是当我运行模拟器时我看不到动作..some1请帮助我
CCAction * action = [CCSequence actions:[CCFadeIn actionWithDuration:2],nil];
for(NSInteger lp = 0;lp<49;lp++)
{
float sizer = [[numberOfElement objectAtIndex:lp]floatValue];
CCSprite *_bar = [CCSprite spriteWithFile:colorOfBar rect: (CGRectMake(10,20,5,sizer*30))];
_bar.position = ccp(5+9.5*lp,((sizer*30)/2)+25);
[self addChild:_bar z:1];
[_bar runAction:action];
}
答案 0 :(得分:1)
您需要为每个节点创建Action实例。
for(NSInteger lp = 0;lp<49;lp++)
{
float sizer = [[numberOfElement objectAtIndex:lp]floatValue];
CCSprite *_bar = [CCSprite spriteWithFile:colorOfBar rect:(CGRectMake(10,20,5,sizer*30))];
_bar.position = ccp(5+9.5*lp,((sizer*30)/2)+25);
[self addChild:_bar z:1];
CCAction * action = [CCSequence actions:[CCFadeIn actionWithDuration:2],nil];
[_bar runAction:action];
}