设置无限随机CCMove

时间:2013-03-05 14:08:05

标签: cocos2d-iphone

只是一个简单的问题 - 设置精灵无限运动序列的最有效方法是什么?我目前正在运行:

-(void) pathToMove:(CCParticleSystemQuad*) system
{
    CGSize screenSize = [[CCDirector sharedDirector] winSize];
    int width = screenSize.width;
    int height = screenSize.height;
    float randX = arc4random() % width;
    float randY = arc4random() % (height - 200);

    CGPoint start = system.position;
    CGPoint end = ccp(randX, randY);

    float finalDistance = ccpDistance(start, end);
    float speedToMove = 500.0;

    float durationToMove = finalDistance / speedToMove;

    [system runAction:[CCSequence actions:[CCMoveTo actionWithDuration:durationToMove position:ccp(randX,randY)],[CCCallFuncN actionWithTarget:self selector:@selector(completedCurve:)],nil]];

}
-(void) completedCurve:(id) sender
{
    [self pathToMove:sender];   
}

但是我担心这可能会导致一些奇怪的僵尸和/或泄漏,通过一次又一次的动作调用。还有更好的方法吗?

0 个答案:

没有答案