0
我是新來的精靈套件.. 我想在x軸上隨機移動一個精靈。 因爲我需要知道如何在動作完成時調用另一個方法/相同的方法以及其他隨機x值。 現在精靈停止在第一個隨機值,並且不會開始移動到下一個值。如何生成 - SKAction - 隨機運動
我嘗試這樣做:
-(void) move:(CGSize)size {
if (x1 == x2) {
x2 = (arc4random() % 320);
e = 0;
}
if (x2 > x1) {
e = x2 - x1;
}
if (x1 > x2) {
e = x1 -x2;
}
t = e/100;
SKAction *action = [SKAction moveToX:x2 duration:e];
[_spriteL runAction: [SKAction repeatAction:action count:1]];
x1 = x2;
[self move:size];
}
感謝