开发者

Cocos2d CCSpirte runAction problems

i am using cocos2d and i have a for loop to create a bunch of sprites, and i am running an action on every sprite in the forloop, however when i run the simulator i cant see the action ..some1 please help me

           CCAction * action = [CCSequence actions:[CCFadeIn actionWithDuration:2],nil];
           for(NSInteger lp = 0;lp<49;lp++)

    {
        float  size开发者_StackOverflowr = [[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];


    }


You need to create Action instance for each node.

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];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜