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

馋奶兔 提交于 2019-12-01 05:20:06

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.

Sprite Kit uses the zPosition value only to determine the hit testing and drawing order.

So you could put all your sprites higher than 0 if you don't want to hit them. And then so a simple logic test is zPostion>0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!