Last active
April 12, 2019 16:34
-
-
Save ohiofi/e2bcba7bae53b3c3f261db27d2700eb2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// At the bottom of override func didMove() | |
// add this below the tapGestureRecognizer | |
let leftSwipe = UISwipeGestureRecognizer(target: self, action: #selector(handleSwipes(_:))) | |
let rightSwipe = UISwipeGestureRecognizer(target: self, action: #selector(handleSwipes(_:))) | |
leftSwipe.direction = .left | |
rightSwipe.direction = .right | |
view.addGestureRecognizer(leftSwipe) | |
view.addGestureRecognizer(rightSwipe) | |
} | |
@objc func handleSwipes(_ sender:UISwipeGestureRecognizer) { | |
if (sender.direction == .left) { | |
print("Swipe Left") | |
skater.position.x -= 5 | |
//let labelPosition = CGPoint(x: skater.position.x - 50.0, y: swipeLabel.frame.origin.y) | |
//swipeLabel.frame = CGRect(x: labelPosition.x, y: labelPosition.y, width: swipeLabel.frame.size.width, height: swipeLabel.frame.size.height) | |
} | |
if (sender.direction == .right) { | |
print("Swipe Right") | |
skater.position.x += 5 | |
//let labelPosition = CGPoint(x: self.swipeLabel.frame.origin.x + 50.0, y: self.swipeLabel.frame.origin.y) | |
//swipeLabel.frame = CGRect(x: labelPosition.x, y: labelPosition.y, width: self.swipeLabel.frame.size.width, height: self.swipeLabel.frame.size.height) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment