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?
I fixed it with :