1

雨のパーティクル レイヤーが SKScene 全体の上にある、非常に単純なパーティクルのセットアップがあります。今、そのレイヤーの下にあるボタンとオブジェクトに触れたいだけです。このレイヤーを最高のzPositionに維持することで、これをどのように達成できますか。(以下のコード)

let rainParticlePath = NSBundle.mainBundle().pathForResource("myRainParticles",
            ofType: "sks")

let rainEmitter = NSKeyedUnarchiver.unarchiveObjectWithFile(rainParticlePath!)
            as! SKEmitterNode

rainEmitter.position = CGPointMake(0,screenSize.height)
rainEmitter.zPosition = 200
rainEmitter.userInteractionEnabled = true

self.addChild(rainEmitter)
4

1 に答える 1

2

nodesAtPoint:を使用しSKNodeて、パーティクル レイヤーの下のノードを含め、タッチした場所をすべて取得します。

例えば:

let nodes = self.nodesAtPoint(touchLocation)
for node in nodes {
    if node.name == "button" {
        // Do something to your 'button'
    }
    else if node.name == "object" {
        // Do something to your 'object'
    }
}
于 2015-11-09T08:06:47.767 に答える