mirror of
https://github.com/avatsaev/touchbar_nyancat
synced 2024-11-24 20:23:06 +00:00
Make nycan cat move back- and forwards.
Moves nan cat till the end of the Touch Bar, then reverses the direction.
This commit is contained in:
parent
b4d2ac444f
commit
22ecae87e5
1 changed files with 6 additions and 2 deletions
|
@ -47,9 +47,13 @@ class NyanCatCanvas: NSImageView {
|
|||
|
||||
}
|
||||
|
||||
var direction: CGFloat = 1
|
||||
@objc public func moveNyancat() {
|
||||
if (xPosition < 0) {
|
||||
xPosition += 1
|
||||
xPosition += direction
|
||||
if xPosition > 0 {
|
||||
direction = -1
|
||||
} else if xPosition < -680 {
|
||||
direction = 1
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue