@Override public void render() { if (platform.getPosition().x > 10) { platform.setLinearVelocity(-PLATFORM_VELOCITY, 0); } else if (platform.getPosition().x < -10) { platform.setLinearVelocity(PLATFORM_VELOCITY, 0); } Gdx.gl.glClearColor(1, 1, 1, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); world.step(1 / 60f, 6, 2); dDebugRenderer.render(world, cam.combined); }
@Override public void render() { update(Gdx.graphics.getDeltaTime()); Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); batch.begin(); batch.draw( texture, player.getPosition().x * PPM - (texture.getWidth() / 2), player.getPosition().y * PPM - (texture.getHeight() / 2)); batch.end(); b2dr.render(world, camera.combined.scl(PPM)); if (Gdx.input.isKeyPressed(Input.Keys.ESCAPE)) Gdx.app.exit(); }
@Override public void render() { Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); camera.position.set(circleBody.getPosition().x, circleBody.getPosition().y, 0); camera.update(); renderer.render(world, camera.combined); System.out.println( "player.getPosition().x = " + player.getPosition().x + "\nplayer.getPosition().y = " + player.getPosition().y + "\ncamera.position = " + camera.position); Sprite sprite; sprite = (Sprite) circleBody.getUserData(); // set position and width and height and makes sure it is in the center sprite.setBounds( convertToWorld(circleBody.getPosition().x) - sprite.getWidth() / 2, convertToWorld(circleBody.getPosition().y) - sprite.getHeight() / 2, convertToWorld(circleShape.getRadius() * 2), convertToWorld(circleShape.getRadius() * 2)); tiledMapRenderer.setView(camera); tiledMapRenderer.render(); System.out.println( "Bouncing circle: " + circleBody.getMass() + "\n" + "Player: " + player.getMass()); // world.step(1/45f, 6, 2); world.step(Gdx.graphics.getDeltaTime(), 4, 4); player.setAwake(true); // camera.project(point.set(player.getPosition().x, player.getPosition().y, 0)); // logger.log(); batch.begin(); // Circle.draw(batch); sprite.draw(batch); batch.end(); }
@Override public void dispose() { world.dispose(); b2dr.dispose(); batch.dispose(); }