Hi, i am using the JBox2D library, I have a problem.
I want to use a little square that is a dynamic object and when i press A or D it moves on left and right; but if i am over the platform it fall like a normal dynamic object. How can I do this?
The movement works but when I fall from the platform the square remain at the same height.
The code I used to move the square is this:
are you actually using jbox2d to set the speed or is speed just a variable ‘added on’ to the jbox 2d coordinates? JBox2d requires you to use functions such as body.setLinearVelocity() and body.applyForce() to interface with the ‘speed’ of the jbox 2d box itself.
if you are just adding the speed to the translate instead of using jbox2d:
translate(pos.x+speed,pos.y);
you are essentially saying: please draw the box ‘speed’ pixels horizontally from where it should be, hence itll never drop off the platform visually, nor even move horizontally according to jbox2d’s coordinates.