0
私はさまざまな定義された位置を経由してramdonlyにジャンプするように鹿を作ろうとしています。アクションのためにループを一時停止する - Swift:Sprite Kit
func deerJumping() {
// The different locations are arranged ramdonly
var places: [CGFloat] = [1124, 852, 1540, 1908, 628, 1736, 392].shuffled()
//Then the for loop with the actions (jumps) between this positions
for posc in places {
//SKAction for the up and down
//SKAction for the displacement left or right
//Code for the deer to face the direction of the jump
//Then run the action:
deer.run(SKAction.group([jump, move]))
}
}
問題は、配列の次の位置に移動する前にループがアクションを完了するのを待っていないことです。
このPause and Resume a for Loop質問があります。ループの中にNSOperation
インスタンスを作成してNSOperationQueue
に追加しようとしていますが、悲しいことに私は初心者です。私のコードにどのように適用するのか分かりません。
ご協力いただければ幸いです。
ありがとうKnightOfDragon。私はそれが動作すると思う! :) – Sersiego
私は次の位置に巡回する前にアクションを実行する時間を作るためにループを一時停止したかったのです。 – Sersiego
私はあなたにフォローしていません。 forループを一時停止すると何もしません – Knight0fDragon