1. 代码
2.然后 schedule 一个 1/30 或者 1/60 的 函数在里面进行检测。
CGRect rect1 = [self positionRect:sheep];
CGRect rect2 = [self positionRect:cow];
if (!CGRectIsNull(CGRectIntersection(rect1, rect2))) {
//handle collision
[sheep stopAction:jump_4ever];
}
本文介绍了一种在游戏开发中实现碰撞检测的方法,并通过代码示例展示了如何使用CGRect来判断两个对象是否发生碰撞。此外,还提到了通过定时调度函数进行碰撞检测的优化方案。
4069

被折叠的 条评论
为什么被折叠?



