-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGameSceneiOSExtensions.swift
40 lines (34 loc) · 1.01 KB
/
GameSceneiOSExtensions.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//
// GameSceneiOSExtensions.swift
// SKSpeedRunJAS1
//
// Created by Jim on 8/23/14.
// Copyright (c) 2014 mutualmobile.com. All rights reserved.
//
import Foundation
import UIKit
extension GameScene {
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
let touch : UITouch = touches.anyObject() as UITouch
let x = touch.locationInNode(self).x
// println("x: \(x), y:\(touch.locationInNode(self).y)")
switch x {
case 0 ..< 256:
currentShipMovement = ShipMovement.Left
case 512 ..< 768:
currentShipMovement = ShipMovement.Right
default:
self.fireLaser()
}
}
override func touchesEnded(touches: NSSet, withEvent event: UIEvent!) {
let touch : UITouch = touches.anyObject() as UITouch
let x = touch.locationInNode(self).x
switch x {
case 0 ..< 256, 512 ..< 768:
currentShipMovement = ShipMovement.None
default:
break
}
}
}