2012-04-12 126 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

相關問題