Andengine - 始终保持身体的相同的速度 [英] Andengine - Always keep the same speed of the body

查看:137
本文介绍了Andengine - 始终保持身体的相同的速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你是侧滚动屏幕中间(播放器),并从enemyes向左或向右continusly出现。

I am developing a game where you are on side scroll on screen middle (player) and enemyes appears from left or right continusly.

我创建了一个敌人,对这种方式设置一个Linearvelocity到右(或左):
getBody.setLinearVelocity(ⅴ* this.getDireccion(),0);

I create a enemy, set a Linearvelocity to right (or left) on this way: getBody.setLinearVelocity(v*this.getDireccion(), 0);

然后,当敌人与另一个敌人或播放器碰撞时,有时会改变方向(他滑回)或获得更多的慢或快。我需要始终具有相同LinearVelocity,如果这个敌人与玩家或另一个怪物碰撞,不停止,不慢,不要太快了,相同的速度和方向。

Then, when the enemy collides with another enemy or player, sometimes change direction (he slides back) or get more slow or fast. I need that always have the same LinearVelocity, and if this enemy is colliding with a player or another monster, dont stop, dont slow, dont fast... same velocity and direction.

任何人都可以帮助我?
对不起,我的英语水平。

Anybody can help me with this? Sorry my english.

推荐答案

如何创建 ContactListener ,然后使用 postSolve 回调方法重置您的身体的速度。结果
碰撞后,Box2D的会产生冲动,避免重叠固定装置,这就是为什么你的身体的速度变化。 这里是一个很好的教程描述碰撞,希望这帮助。

How about create the ContactListener, and use the postSolve callback method to reset your body velocity.
After collision, Box2D will generate impulse to avoid fixtures overlap, that's why the speed of your body is changed. Here is a good tutorials describe the collision, hope this help.

这篇关于Andengine - 始终保持身体的相同的速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆