动态图像和玩家移动图像碰撞检测

发布于 2024-11-01 03:12:08 字数 285 浏览 2 评论 0原文

我正在开发小游戏,奖励阶段就在那里。动态创建的星星(UIImageView)很少。当玩家触摸这些星星时,就会获得分数。 Player(UIImageView) 可以从左到右感应加速度计数据移动,如果星星处于某个高度,也可以跳跃。

然而,我无法适应玩家和星星图像之间的碰撞逻辑,因为这些星星是在随机位置动态创建的,如何感知星星和玩家之间的交叉点。

我应该使用一些计时器来连续检查星星和玩家之间的交集吗?我认为这不是正确的解决方案,因为它会消耗太多内存。

请建议我一些机制,以便我可以进一步进行。如何做到这一点?

I am working on small game and in that bonus stage is there. There are few stars(UIImageView) available dynamically created. When Player touches those stars it gets points. Player(UIImageView) can move on sensing accelerometer data from left to right and also can Jump if stars are at some height.

However I am unable to fit the logic for collision between Player and Star Image as those stars are being created dynamically at random positions how to sense intersections between Star and Player.

Should I use some timer which continuously checks for intersection between star and Player? This is not proper solution I believe as it will consume too much memory.

Please suggest me some mechanism so that I can proceed further. How to do this ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏日落 2024-11-08 03:12:08

不需要计时器,只需将碰撞检测放在处理玩家移动的同一位置即可。(即,在移动玩家的 UIImageView 后,测试它是否接触到任何星星)

(顺便说一句,您应该保留一个数组引用可用的恒星以便能够测试它们的碰撞)

No need for timers, just put your collision detection in the same place where you are handling player movement.(i.e., after you have moved player's UIImageView, test to see if it is touching any star)

(BTW, you should keep an array with references to the available stars to be able to test them for collisions)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文