动态图像和玩家移动图像碰撞检测
我正在开发小游戏,奖励阶段就在那里。动态创建的星星(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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不需要计时器,只需将碰撞检测放在处理玩家移动的同一位置即可。(即,在移动玩家的 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)