2012-04-12 78 views

回答

1

为了与调度方法使用,你可以使用下面的代码

[self schedule:@selector(moveAction1:)]; // This code goes wherever you need to start scheduling 

-(void) moveAction1 : (ccTime) dt 
{ 
    [spriteName setPosition:ccp(xPosition,yPosition)]; 
    xPosition += 0.1f; 
    yPosition += 0.1f 
    if(xPosition == 320) 
     [self unschedule:@selector(moveAction1:)]; 
} 

上面的代码会为你工作。

我强烈建议使用ccMoveTo而不是此代码。

+0

为什么你推荐使用ccMoveTo代替? – cstack 2012-06-13 16:58:02

+0

由于ccMoveTo的执行速度会更快,并且也会减少代码行。这就是我推荐ccMoveTo的原因。 – Marine 2012-06-18 07:57:29

相关问题