Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import SpriteKit
- let plankName = "woodPlank"
- class PlankScene: SKScene {
- var plankWood : SKSpriteNode?
- override func didMove(to view: SKView) {
- plankWood = childNode(withName: "woodPlank") as? SKSpriteNode
- let swipeRight : UISwipeGestureRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(PlankScene.swipedRight))
- swipeRight.direction = .right
- view.addGestureRecognizer(swipeRight)
- }
- func swipedRight(sender: UISwipeGestureRecognizer) {
- if sender.direction == .right {
- let moveOffScreenRight = SKAction.moveTo(x: 400, duration: 0.5)
- let nodeFinishedMoving = SKAction.removeFromParent()
- plankWood?.run(SKAction.sequence([moveOffScreenRight, nodeFinishedMoving]))
- plankWood?.position = CGPoint(x: 0, y: -250)
- addChild(plankWood!)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement