【发布时间】:2020-02-05 22:32:38
【问题描述】:
对于我正在创建的游戏,SKSpriteNode 逐渐出现在用户屏幕上。屏幕底部附近还有另一个 SKSpriteNode(位置是静态的),只为原始 SKSpriteNode 留下一点空间来适应。我需要检测第一个 SKSpriteNode 何时完全低于我拥有的第二个 SKSpriteNode有点麻烦。这是我目前正在使用的代码:
if (pos.y > barPosY) //pos.y = 1st SKSpriteNode, barPosY = 2nd SKSpriteNode
{
touchedTooEarly = true
}
由于某种原因,当第一个 SKSpriteNode 稍微超过第二个 SKSpriteNode(不是一直)时,它仍然检测到它完全结束了。有没有我遗漏的坐标空间问题?
【问题讨论】:
-
你没有考虑精灵的高度,你需要确保
pos.y - pos.frame.height/2 > barPosY + bar.frame.height/2
标签: ios sprite-kit