Custom SKSpriteNode not detected during touch

前端 未结 5 785
一整个雨季
一整个雨季 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:49

    Your ADVHeroNode is either a SkNode or SkSpriteNode with no image. Neither will have any extents, they're points so to speak. They will not be found by nodeAtPoint: but the image child SKSpriteNode will. Since you're explicitly checking for the node's name, the check fails.

    You could give the image a name, and check for that and then refer to its parent to gethe ADVHeronode instance. Or just check node.parent's name directly.

提交回复
热议问题