我可以让CCFollow跟随更自然吗?
我想用cocos2d/Box2D构建一个平台游戏。我使用 CCFollow 来跟随玩家精灵,但 CCFollow 不断将其放置在屏幕中央。我希望 CCFollow 能够更自然地跟随,就像人类转动摄像机一样,具有可接受的滞后、小超调等。
这是我的一种不起作用的方法:我将一个小型物理体(通过距离关节)附加到玩家身上,该物体不会与任何物体发生碰撞,由透明精灵表示。我CCFollow了透明精灵。我希望这个幽灵身体能像气球一样附着在玩家身上,从而实现视野的平滑转移。问题是距离关节因太重或太轻的物体而断裂。气球随机移动,当然,无论它有多轻,它都会将玩家拉回来一点。
平滑地跟随移动精灵的更好方法是什么?
I want to build a platform game with cocos2d/Box2D. I use CCFollow to follow the player sprite but CCFollow constantly puts it in the center of the screen. I want CCFollow to follow more naturally, like a human turning a camcorder with an acceptable lag, a small overshoot ...etc.
Here is a method of mine that didn't work: I attached (via a distance joint) a small physics body to the player that doesn't collide with anything, represented by a transparent sprite. I CCFollow'ed the transparent sprite. I was hoping this ghost body would act like a balloon attached to the player, hence a smooth shift in view. The problem is distance joint breaks with too heavy - too light objects. The balloon moves around randomly, and of course, it pulls the player back a little no matter how light it is.
What is a better way of following a moving sprite smoothly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试将其添加到 cocos2d 库中的 CCActions 中。
我从 cocos2d 论坛得到这个。
Try add this to CCActions in cocos2d libs.
i get this from cocos2d forums.
也许这个 http://www.cocos2d-iphone.org/wiki/doku .php/prog_guide:actions_ease 可以帮助您通过CCFollow获得“加速”效果。
Perhaps this http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:actions_ease can help you get an "acceleration" effect with CCFollow.