Cocos2d / Box2d - 动画“捕捉到网格”影响
我正在使用 cocos2d 和 box2d,尝试开发一款游戏,其中图块在网格中滑动。
到目前为止一切都进展得相当顺利,但我试图在用户移动图块后在图块上实现“对齐网格”效果,其中图块动画到正确的位置,但然后短暂地围绕正确的位置,因为它“固定”到位。
有谁对如何最好地实现这一目标有任何想法?我尝试过使用距离接头,并尝试了频率和阻尼比,但为了达到效果,我需要将接头的长度减少到 0,因为瓷砖主体会卡入到位。这对于距离接头是否可行,并且这样做实际上会将瓷砖主体“拉”到位吗?
任何关于如何最好地解决这个问题的想法将不胜感激。
谢谢,特德
I'm playing around with cocos2d and box2d, trying to develop a game where tiles are slid around in a grid.
It's all gone fairly well so far, but i'm try to achieve a 'snap to grid' effect on the tiles after they've been moved by the user, where the tile animates into the correct position, but then briefly oscillates around the correct position, as it 'settles' into place.
Does anyone have any thoughts on how best to achieve this? I've tried using distance joints, and experimenting with the frequency and damping ratio, but to achieve the effect i'd need to reduce the length of the joint down to 0, as the tile body snaps into place. Is this possible with a distance joint, and would doing so actually 'pull' the tile body into place?
Any ideas on how best to approach this would be much appreciated.
Thanks, Ted
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最后我们根本没有使用 box2d,因为我们似乎是在与它的物理世界作斗争,而不是使用它的功能。
这些图块被编码为简单地跟随屏幕上的拖动,虽然遗憾的是我们从未设法通过捕捉来实现振荡效果,但我们确实设法获得了“挤压”效果。通过在图块之间留出边距,并允许它们在碰撞检测开始之前移动到另一个图块的“空间”中,然后在用户释放拖动时弹回到正确的位置。
In the end we didn't use box2d at all, as we seemed to be fighting its physics world, more than using its features.
The tiles were coded to simply follow a drag on the screen, and while sadly we never did manage to achieve the oscillation effect with the snap to, we did manage to get a 'squashing' effect instead. By having a margin between tiles, and allowing them to move over into another tile's 'space' before a collision detection began, and then springing back into their correct places when the user released the drag.