Custom SKSpriteNode not detected during touch

前端 未结 5 805
一整个雨季
一整个雨季 2020-12-15 09:06

In learning SpriteKit, I am trying to make a small adventure game. I am creating a hero, and adding it to the scene, and then later, during touchesBegan:, I det

5条回答
  •  清歌不尽
    2020-12-15 09:46

    I usually check the touched node's parent until i find the class i want to control. Here's a code snippet.

    while (touchedNode.parent)
        {
            if ([touchedNode isKindOfClass:[GameObject class]])
                break;
            else
                touchedNode = (SKSpriteNode*)self.touchedNode.parent;
        }
    

提交回复
热议问题