SHARE
TWEET

Untitled

a guest Oct 18th, 2015 6 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         public void render() {
  2.                 Gdx.gl.glClearColor(0, 0, 0, 1);
  3.                 Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
  4.                 world.step(1/ 60f, 8, 3);
  5.                 camera.position.set(playerBody.getPosition().x, playerBody.getPosition().y, 0);
  6.                 camera.update();
  7.                 mapRenderer.render();
  8.                 mapRenderer.setView(camera);
  9.                 if (playermoving)
  10.                         movePlayer(); // linear velocity of player by +100 per .1 seconds
  11.                 batch.setProjectionMatrix(camera.combined);
  12.                 batch.begin();
  13.                 world.getBodies(tmpBodies);
  14.                 for(Body body : tmpBodies) { // loops through (10) bodies and if userdata is sprite then draw the sprite at body pos.
  15.                         if (body.getUserData() != null && body.getUserData() instanceof Sprite) {
  16.                                 Sprite sprite = (Sprite) body.getUserData();
  17.                                 sprite.setPosition(body.getPosition().x - sprite.getWidth() / 2, body.getPosition().y - sprite.getHeight() / 2);
  18.                                 sprite.setRotation(body.getAngle() * MathUtils.radiansToDegrees);
  19.                                 sprite.draw(batch);
  20.                         }
  21.                 }
  22.                 batch.end();
  23.                 box2DDebugRenderer.render(world, camera.combined);
  24.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top