member2 member2 - 1 year ago 106
Android Question

Moving faster in libgdx?

My Question is how can I move my character faster if a certain button is pressed? I tried it with stepSimulation() from btDynamicsWorld. Also did I set different values but the only result was that the fps dropped dramatically. So which methods can u use to control the movement of the character? I just try to get into android games developement.

Answer Source

You should follow some basic LibGDX tutorials. In any tutorial where you can move a character, find out where the character's x and y coordinates are being set on input. When the "certain button" is pressed, just change the multiplier that affects movement.

For example, in the official tutorial they have this code in the render method:

if(Gdx.input.isKeyPressed(Keys.LEFT)) bucket.x -= 200 *;
if(Gdx.input.isKeyPressed(Keys.RIGHT)) bucket.x += 200 *

Here the multiplier is 200. Change the multiplier and the speed will change.

(If you're just getting started, you should follow some simple tutorials step-by-step, and preferably on desktop because it's easier to work.)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download