iOS7 Sprite Kit how to disable touches on a sprite to make it “tap through”?

后端 未结 2 1225
挽巷
挽巷 2021-01-12 04:38

I know that for traditional UIViews, I can set \"enable user interaction\" flag to NO, and the view will no longer respond to touches, letting the views below them receive t

2条回答
  •  甜味超标
    2021-01-12 05:34

    If you set the userInteractionEnabled property to YES on a subclassed SKSpriteNode, then the touch delegates will called within the class. Hence, you can handle the touch for the sprite within its class.

    However, by default, the userInteractionEnabled property is set to NO. Hence the touch on a sprite is, by default, a "tap through".

    So, for the overlays you want, create custom classes for the sprites, implement the touchesBegan: and other delegates within that class and while initialising, set the userInteractionEnabled property to YES.

提交回复
热议问题