开发者

CCSprite runAction and Remove

I have a ccLayer where I'm trying to make it rain. On init i schedule the following:

        [self schedule:@selector(throwRain) interval:0.1f];

And here is the rest of the code:

-(void) throwRain {
    CCSprite *gota;
    for (int i = 1; i <= 6; i++){
        gota = [CCSprite spriteWithFile:@"4_gota.png"];
        gota.position = ccp开发者_StackOverflow(arc4random() % 768, 1060);
        gota.scale = (arc4random () % 25 + 50.0f) / 100.0f;
        gota.rotation = 35 ;
        [self addChild:gota z:arc4random() % 5 + 7];

        [gota runAction:[CCSequence actions:[CCEaseRateAction actionWithAction:[CCMoveTo actionWithDuration:3.0f + (arc4random() % 200) / 100.0f position:ccp(gota.position.x, 0)] rate:3]  , [CCCallFunc actionWithTarget:self selector:@selector(spriteDone:)], nil]];
    }
}

-(void) spriteDone:(id)sender {
    [self removeChild:sender cleanup:YES];
}   

However, the drops gets to the bottom and just stays there, and never gets removed. Any idea? Thanks.


Try changing from CCCallFunc to CCCallFuncN. The 'N' stands for Node, and will pass the Node that is performing the action to the selector.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜