touchesBeganが動作しない
このようなプログラムを、XcodeのPlaygroundで作りました
しかし、touchesBeganが動作しません
上手く行けば、「touched」と表示されるはずなのですが、表示されません
import UIKit
import SpriteKit
import PlaygroundSupport
class set: SKScene {
//var Progress = 0
//var button: SKNode? = nil
func start() {
let sceneWidth = 450.0
let sceneHeight = 800.0
//var ProcessSeed = 0
let sceneView = SKView(frame: CGRect(x: 0.0, y: 0.0, width: sceneWidth, height: sceneHeight))
PlaygroundPage.current.liveView = sceneView
let back: SKScene = SKScene(size: CGSize(width: sceneWidth, height: sceneHeight))
back.backgroundColor = UIColor.white
sceneView.presentScene(back)
let character = SKSpriteNode(imageNamed: "SobacchiStand.png")
character.position = CGPoint(x: sceneWidth/2, y: sceneHeight/2)
character.xScale = 0.5;
character.yScale = 0.5;
back.addChild(character)
let button = SKSpriteNode(imageNamed: "Button.png")
button.xScale = 0.1;
button.yScale = 0.1;
button.position = CGPoint(x: 400.0, y:100.0)
button.zPosition = 1
button.name = "button"
back.addChild(button)
button.isUserInteractionEnabled = true
}
func doit() {
print("実行")
print("されています")
}
/* override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
if let touch = touches.first as UITouch? {
let location = touch.location(in: self)
if self.atPoint(location).name == "button" {
print("button tapped")
}
}
}*/
override func touchesBegan(_ touches: Set<UITouch>,with event: UIEvent?)
{ //super.touchesBegan(touches, with: event)
print("touched")
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesEnded(touches, with: event)
print("touchend")
}
}
let first = set()
let second = first.start()
var Progress = 0
/*while Progress <= 100 {
first
}*/
エラー自体は出ていない上、どのサイトを見ても、間違っている点が見当たらないのですが、どこか間違っているのでしょうか?