如何在swift SKSpriteNode中添加按钮效果

如何在swift SKSpriteNode中添加按钮效果,swift,button,skspritenode,Swift,Button,Skspritenode,我有一个Var按钮 var soundButton: SKSpriteNode! = nil 而细节则是如此 soundButton = SKSpriteNode(imageNamed: "\(soundImg)") soundButton.position = CGPoint(x: frame.size.width*0.08 , y:frame.size.width*0.08); soundButton.size = CGSizeMake(fram

我有一个Var按钮

var soundButton: SKSpriteNode! = nil
而细节则是如此

soundButton           =   SKSpriteNode(imageNamed: "\(soundImg)")
soundButton.position  =   CGPoint(x: frame.size.width*0.08 , y:frame.size.width*0.08);
soundButton.size      =   CGSizeMake(frame.size.width*0.10,frame.size.width*0.10 )
self.addChild(soundButton)

当我点击按钮并发出声音时,如何添加按钮效果,如按钮彩色灯光。

一种方法是,当选择按钮时,您可以更改图像

像这样进入您的
触摸开始
方法:

override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
    /* Called when a touch begins */

    for touch in (touches as! Set<UITouch>) {
        let location = touch.locationInNode(self)

        if self.nodeAtPoint(location) == self. soundButton {
            soundButton.texture = SKTexture(imageNamed: "soundSelected")

        }
    }
}

还有一件事,当我点击按钮时,视图会切换到另一个屏幕。那我怎么用延时呢。所以它正确地显示了。现在它可以快速改变视图。在按钮上显示更改图像后,是否有任何方法可以不显示另一个屏幕。如果下一个按钮.containsPoint(位置){nextButton=SKSpriteNode(图像名为:“button2”)让显示=SKTransition.flipHorizontalWithDuration(0.5)让shopScene=shopScene(大小:self.size,控制器:self.vc)self.view?.presentScene(商店场景,过渡:显示)}
let reveal = SKTransition.flipHorizontalWithDuration(0.5)
let letsPlay = playScene(size: self.size)
self.view?.presentScene(letsPlay, transition: reveal)