質問するログイン新規登録

質問編集履歴

1

ソースコードを一部書き換えました

2017/04/02 18:28

投稿

Kenelaoy
Kenelaoy

スコア50

title CHANGED
File without changes
body CHANGED
@@ -5,7 +5,9 @@
5
5
  import PlaygroundSupport
6
6
 
7
7
  class set: SKScene {
8
+ //var Progress = 0
8
- var button: SKNode? = nil
9
+ //var button: SKNode? = nil
10
+
9
11
  func start() {
10
12
  let sceneWidth = 450.0
11
13
  let sceneHeight = 800.0
@@ -22,34 +24,46 @@
22
24
  character.yScale = 0.5;
23
25
  back.addChild(character)
24
26
 
25
- button = SKSpriteNode(imageNamed: "Button.png")
27
+ let button = SKSpriteNode(imageNamed: "Button.png")
26
- button?.xScale = 0.1;
28
+ button.xScale = 0.1;
27
- button?.yScale = 0.1;
29
+ button.yScale = 0.1;
28
- button?.position = CGPoint(x: 400.0, y:100.0)
30
+ button.position = CGPoint(x: 400.0, y:100.0)
29
- button?.zPosition = 1
31
+ button.zPosition = 1
30
- button?.name = "button"
32
+ button.name = "button"
31
- back.addChild(button!)
33
+ back.addChild(button)
32
34
 
33
- button?.isUserInteractionEnabled = true
35
+ button.isUserInteractionEnabled = true
34
36
  }
37
+ func doit() {
38
+ print("実行")
39
+ print("されています")
40
+ }
35
41
 
36
- override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
42
+ /* override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
37
- for touch in touches {
43
+ if let touch = touches.first as UITouch? {
38
- let location = touch.location(in: self)
44
+ let location = touch.location(in: self)
39
-
40
- if (button?.contains(location))! {
45
+ if self.atPoint(location).name == "button" {
41
- print("button touched")
46
+ print("button tapped")
42
-
47
+ }
43
48
  }
44
- else {
49
+ }*/
50
+ override func touchesBegan(_ touches: Set<UITouch>,with event: UIEvent?) { //super.touchesBegan(touches, with: event)
45
- //start the game here
51
+ print("touched")
46
- }
47
52
  }
53
+ override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
54
+ super.touchesEnded(touches, with: event)
55
+ print("touchend")
48
56
  }
49
57
  }
50
58
 
51
59
  let first = set()
52
60
  let second = first.start()
61
+ var Progress = 0
62
+
63
+ /*while Progress <= 100 {
64
+ first
65
+ }*/
66
+
53
67
  ```
54
68
 
55
69
  しかし、touchesBeganが動作しません