AndEngine Box2D 强制移动下落的角色
我正在开发一款横向卷轴游戏,例如《超级马里奥》。我正在尝试使用 setLinearVelocity() 移动角色,但这似乎无法正常工作。当角色跌倒然后开始移动时,他不会继续跌倒而只会移动。
这是一个代码片段:
Sprite backward = new Sprite( -50, CAMERA_HEIGHT - 170, backwardr){
@Override
public boolean onAreaTouched(TouchEvent pEvent, float pX, float pY){
if(!pEvent.isActionUp()){
charactersprite.getTextureRegion().setFlippedHorizontal(true);
body.setLinearVelocity(new Vector2(3,0)); // There's the problem
}else{
body.setLinearVelocity(new Vector2(0,0)); // Don't look at there
}
return false;
}
};
有人可以帮助我吗?
I'm developing a side-scroller game like Super Mario. I'm trying to move a character using setLinearVelocity()
, but this doesn't seem to work properly. When the character falls and then starts moving, he doesn't continue to fall but only moves.
This is a code snippet:
Sprite backward = new Sprite( -50, CAMERA_HEIGHT - 170, backwardr){
@Override
public boolean onAreaTouched(TouchEvent pEvent, float pX, float pY){
if(!pEvent.isActionUp()){
charactersprite.getTextureRegion().setFlippedHorizontal(true);
body.setLinearVelocity(new Vector2(3,0)); // There's the problem
}else{
body.setLinearVelocity(new Vector2(0,0)); // Don't look at there
}
return false;
}
};
Could anyone please help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我用以下方法修复了它:
I fixed it with :