Swift Playgroundで以下のようなプログラムを作成しています(前に質問させていただいたものと同じです)
Swift
1import UIKit 2import SpriteKit 3import PlaygroundSupport 4 5class set: SKScene { 6 //var Progress = 0 7 //var button: SKNode? = nil 8 9 func start() { 10 let sceneWidth = 450.0 11 let sceneHeight = 800.0 12 //var ProcessSeed = 0 13 let sceneView = SKView(frame: CGRect(x: 0.0, y: 0.0, width: sceneWidth, height: sceneHeight)) 14 PlaygroundPage.current.liveView = sceneView 15 let back: SKScene = SKScene(size: CGSize(width: sceneWidth, height: sceneHeight)) 16 back.backgroundColor = UIColor.white 17 sceneView.presentScene(back) 18 19 let character = SKSpriteNode(imageNamed: "SobacchiStand.png") 20 character.position = CGPoint(x: sceneWidth/2, y: sceneHeight/2) 21 character.xScale = 0.5; 22 character.yScale = 0.5; 23 back.addChild(character) 24 25 let button = SKSpriteNode(imageNamed: "Button.png") 26 button.xScale = 0.1; 27 button.yScale = 0.1; 28 button.position = CGPoint(x: 400.0, y:100.0) 29 button.zPosition = 1 30 button.name = "button" 31 back.addChild(button) 32 33 button.isUserInteractionEnabled = true 34 } 35 func doit() { 36 print("実行") 37 print("されています") 38 } 39 40 /* override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { 41 if let touch = touches.first as UITouch? { 42 let location = touch.location(in: self) 43 if self.atPoint(location).name == "button" { 44 print("button tapped") 45 } 46 } 47 }*/ 48 override func touchesBegan(_ touches: Set<UITouch>,with event: UIEvent?) { //super.touchesBegan(touches, with: event) 49 print("touched") 50 } 51 override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) { 52 super.touchesEnded(touches, with: event) 53 print("touchend") 54 } 55} 56 57let first = set() 58let second = first.start() 59var Progress = 0 60 61/*while Progress <= 100 { 62 first 63}*/ 64
しかし、touchesBeganが動作しません
画像の表示までは上手く出来ているのですが・・・
エラーも出ておらず、qiitaなどで書かれているコードとも大きな違いが見受けられないため、余計に混乱しています
どのようにしたら動作するようになるのでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。