在碰撞检测回调中检查以下内容。
if(y-origin of the first animal + its height < the y-origin of the second animal){
//then do the logic for walking on top of another animal (probably nothing would happen here depending on what you are trying to build)
}
else {
//forward to collision logic (e.g life loss, lose points, restart level ,etc..)
}
如果第一只动物有可能进入第二只动物的下方,那么您需要将您的状况更新为以下
if(firstAnimal.origin.y + firstAnimal.frame.size.height < secondAnimal.frame.origin.y
|| firstAnimal.origin.y > secondAnimal.frame.origin.y + secondAnimal.frame.size.height)
小心不同的坐标系,有时可能会令人困惑。希望这会有所帮助,请随时询问是否有任何不清楚的地方。