Skip to content

Commit

Permalink
remove unneeded public functions
Browse files Browse the repository at this point in the history
  • Loading branch information
amiantos committed Jan 29, 2022
1 parent 606fce2 commit a040f72
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 48 deletions.
48 changes: 6 additions & 42 deletions Shared/Scene/ClockController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ class ClockController {
startTimer()
}
}

public func queue(animations: [Animation]) {
animationQueue.append(contentsOf: animations)
startAnimationQueueIfNeeded()
}

// MARK: - Timer

Expand Down Expand Up @@ -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)
Expand All @@ -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(),
])
}

}
12 changes: 6 additions & 6 deletions Shared/Scene/ClockScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit a040f72

Please sign in to comment.