Search code examples
iosswiftxcodesprite-kittouchesbegan

Can I access to touched node properties in touchBegan method in swift?


I want to know a property of the touched node and then change it without using node name.


Solution

  • Yes, in the touchesBegan method override you have full access to self. so can do anything you want with the node from there.

    Similarly, in the other touchesEnded, touchesMoved

    If you're coming from Unity, the biggest difference is the lack of update and fixedUpdate access inside the nodes. You can only get at this game loop stuff from within the Scene node.

    However... if you use GameplayKit, you can use Entities, and then think in much the same way you would in Unity about composition and the game loop.