Ich möchte 2 Würfel für immer animieren, bis der Benutzer einen davon tippt. Die Animation soll wie ein ∞ sein.Animiere SCNNode für immer - SceneKit, Swift
Das sind meine Würfel in der sceneView Ich möchte animieren:
Ich versuche, mit verschachtelten Animationen zu tun, und es teilweise nicht funktioniert. Jetzt, da die Animationen immer warten, bis sie fertig sind, bevor sie neu gestartet werden, sieht es überhaupt nicht glatt aus.
Bevor ich mit der Entwicklung der ∞-Animation fortfahre, würde ich gerne wissen, ob es einen besseren (und tatsächlich funktionierenden) Weg gibt. Dies ist mein aktueller Code:
SCNTransaction.begin()
SCNTransaction.setAnimationDuration(2)
cube1.position = SCNVector3Make(3, 0, 0)
cube2.position = SCNVector3Make(-3, 0, 0)
println("log 0")
SCNTransaction.setCompletionBlock {
println("log 1")
while (animationKey != 1) {
//initially animationKey = 0
SCNTransaction.begin()
SCNTransaction.setAnimationDuration(2)
cube1.position.x += 1
cube1.position.y += 1
cube2.position.x += 1
cube2.position.y += 1
println("log 2")
SCNTransaction.setCompletionBlock {
SCNTransaction.begin()
SCNTransaction.setAnimationDuration(2)
cube1.position.x -= 1
cube1.position.y -= 1
cube2.position.x -= 1
cube2.position.y -= 1
println("log 3")
SCNTransaction.setCompletionBlock { animationKey = 1 }
SCNTransaction.commit()
}
println("log 4")
SCNTransaction.commit()
}
}
println("log 5")
SCNTransaction.commit()
println("log 6")
}
Der Ausgang folgende Dinge zeigt: log 0, log 5, log 6, log 1, log 2, log 4, log 2
... und dann geht es weiter nur mit log 4
und log 2
abwechselnd.
Kann mir jemand helfen?
Hinweis
dachte ich eine rekursive Ansatz wäre besser, ich mehr daher ersetzt
animationKey = 1
mit dem Aufruf der Methode, dies in ist ... überhaupt nicht arbeiten.bekam ich die Animationen einmal zu arbeiten, aber es hält nun direkt nach der ersten Animation Finishing und ignoriert die 2. und 3. Animation Block ...
Ok, das ist schon großartig. Gibt es eine Möglichkeit, der SCNAction Optionen zuzuweisen? So wie zum Beispiel 'CurveEaseIn'. Die Sache ist, ich will, dass es glatt ist, aber gerade jetzt beendet es gerade die Animation und beginnt das folgende danach ...:/ – LinusGeffarth
action.timingMode = SCNActionTimingModeEaseInEaseOut; –
Cool, danke :) – LinusGeffarth