Receive touch events at SKScene AND SKSpriteNode in SpriteKit
Asked Answered
O

0

1

Building a UI with buttons as SKSpriteNode's. Button sprites receive touch events to handle special effects (elastic scaling effects) But I need the SKScene to handle the touch events at the same time to handle UI navigation logic.

How would be possible to both (sprite AND scene) to handle these touch events?

Onestep answered 25/1, 2016 at 7:24 Comment(4)
Have a look at this: gist.github.com/bobmoff/7110052. It's in Obj-c, hope that's not an issuePincushion
@Pincushion this is interesting, however I can't apply it to this case. I'm looking for the Scene to receive the touch event at the same time as the sprite.Onestep
You can forward the touch event to the scene after the button receives/handles the touch. You can also disable touches in the button and handle touches in the scene and call a method in the button class to scale, highlight, etc. the button.Pursuit
Probably my approach was not entirely valid at all. I've resolved the issue where the sprite receives the touch and notifies the scene via a selector a la UIButton.Onestep

© 2022 - 2024 — McMap. All rights reserved.