ボタンを押したときにシーンを切り替えようとしていますが、クリックすると何も起こりません。何も表示されません。エラーはありません、なぜ私はそれが動作していないのだろうかと思っています。 私がプログラムしたノードは正しいサイズと場所で表示されますが、タップすると何も通過しません。何か助けてくれてありがとう。シーンをボタンノードで切り替えるとエラーが発生する
コード:
class LevelScene: SKScene, SKPhysicsContactDelegate {
var isFingerOnBlock = false
let LevelOneName = "levelOne"
override func didMove(to view: SKView) {
super.didMove(to: view)
let Pineapple = SKSpriteNode(imageNamed: "ball")
Pineapple.isUserInteractionEnabled = true
Pineapple.position = CGPoint(x: self.frame.midX - 200, y: self.frame.midY);
Pineapple.name = "pineapple"
addChild(Pineapple)
}
func touchesBegan(touches: NSSet, withEvent event: UIEvent)
{
let touch = touches.anyObject() as! UITouch
let location = touch.location(in: self)
let nodes = self.nodes(at: location)
for node in nodes
{
if node.name == "pineapple"
{
print("ceeds")
if let scene = GameScene(fileNamed:"GameScene") {
// Configure the view.
let skView = self.view!
skView.showsFPS = true
skView.showsNodeCount = true
/* Sprite Kit applies additional optimizations to improve rendering performance */
skView.ignoresSiblingOrder = true
/* Set the scale mode to scale to fit the window */
scene.scaleMode = .aspectFit
skView.presentScene(scene)
}
break
}
}
}
}
あなたはこの機能を実装しようと思っていますか? https://developer.apple.com/documentation/uikit/uiresponder/1621142-touchesbegan – matt