0

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

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

但我担心这可能会导致一些奇怪的僵尸和/或通过一个动作一遍又一遍地调用自身而导致泄漏。有没有更好的办法?

4

0 回答 0