diff --git a/Shared/Scene/ClockController.swift b/Shared/Scene/ClockController.swift index 44774ac..f1a0a63 100644 --- a/Shared/Scene/ClockController.swift +++ b/Shared/Scene/ClockController.swift @@ -63,6 +63,11 @@ class ClockController { startTimer() } } + + public func queue(animations: [Animation]) { + animationQueue.append(contentsOf: animations) + startAnimationQueueIfNeeded() + } // MARK: - Timer @@ -238,11 +243,6 @@ class ClockController { scene?.run(actionGroup) } - public func queue(animations: [Animation]) { - animationQueue.append(contentsOf: animations) - startAnimationQueueIfNeeded() - } - private func runNextAnimation() { let animation = animationQueue.removeFirst() run(animation) @@ -253,41 +253,5 @@ class ClockController { runNextAnimation() } } - - // Helper functions for manually triggering animations - - public func showCurrentTime() { - queue(animations: [Animation.currentTimePrint()]) - } - - public func showTime(string: String) { - queue(animations: [Animation.printString(string: string)]) - } - - public func returnToMidnight() { - queue(animations: [Animation.positionBothHands(minuteDegrees: 0, hourDegrees: 0)]) - } - - public func moveAll(degrees: CGFloat) { - queue(animations: [Animation.positionBothHands(minuteDegrees: degrees, hourDegrees: degrees)]) - } - - public func moveAll(minuteDegrees: CGFloat, hourDegrees: CGFloat) { - queue(animations: [Animation.positionBothHands(minuteDegrees: minuteDegrees, hourDegrees: hourDegrees)]) - } - - public func setAllToCurrentTime() { - queue(animations: [Animation.currentTimeClock()]) - } - - public func rotateAll(by degrees: CGFloat) { - queue(animations: [Animation.spinBothHands(by: degrees)]) - } - - public func testQueue() { - queue(animations: [ - Animation.spinBothHands(by: 360), - Animation.currentTimePrint(), - ]) - } + } diff --git a/Shared/Scene/ClockScene.swift b/Shared/Scene/ClockScene.swift index 7119365..f333d28 100644 --- a/Shared/Scene/ClockScene.swift +++ b/Shared/Scene/ClockScene.swift @@ -70,17 +70,17 @@ class ClockScene: SKScene, ManagerDelegate { Animation.positionBothHands(minuteDegrees: 0, hourDegrees: 0), ]) case "t": - controller?.showCurrentTime() + controller?.queue(animations: [Animation.currentTimePrint()]) case "w": - controller?.returnToMidnight() + controller?.queue(animations: [Animation.positionBothHands(minuteDegrees: 0, hourDegrees: 0)]) case "x": - controller?.moveAll(degrees: -45) + controller?.queue(animations: [Animation.positionBothHands(minuteDegrees: -45, hourDegrees: -45)]) case "c": - controller?.moveAll(minuteDegrees: -45, hourDegrees: -225) + controller?.queue(animations: [Animation.positionBothHands(minuteDegrees: -45, hourDegrees: -225)]) case "r": - controller?.setAllToCurrentTime() + controller?.queue(animations: [Animation.currentTimeClock()]) case "p": - controller?.rotateAll(by: 360) + controller?.queue(animations: [Animation.spinBothHands(by: 360)]) case "o": controller?.queue(animations: [ Animation.display(pattern: horizontalLinesPattern),