@Override
public void render() {
world.step(Gdx.app.getGraphics().getDeltaTime(), 3, 3);
...
}
// called when the user presses a "fire" button.
private void fireCannon() {
Body bullet = ...;
bullet.setActive(true);
bullet.setTransform(CONST_LOCATION_X, CONST_LOCATION_Y, 0);
bullet.setLinearVelocity(0, 0);
bullet.applyLinearImpulse(
10, // impulse x
20, // impulse y
CONST_LOCATION_X,
CONST_LOCATION_Y);
}
accumulator += delta;
while (accumulator >= stepTime)
{
step(stepTime);
accumulator -= stepTime;
}Users browsing this forum: No registered users and 2 guests