Game Development Reference
In-Depth Information
Next, we update the render() method as follows:
@Override
public void render() {
Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.
getHeight());
Gdx.gl.glClearColor(.2f, 0.2f, 0.2f, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
float delta = Gdx.graphics.getDeltaTime();
worldInstance.update(delta);
for (UserData data : UserData.data) {
if (!data.isVisible(cam)) {
worldInstance.remove(data.getBody());
}
}
modelBatch.begin(cam);
for (UserData data : UserData.data) {
modelBatch.render(data.getInstance(), environment);
}
modelBatch.end();
batch.setProjectionMatrix(guiCam.combined);
batch.begin();
font.draw(batch, "FPS: " + Gdx.graphics.getFramesPerSecond(), 0, Gdx.
graphics.getHeight());
box.draw(batch);
cone.draw(batch);
cylinder.draw(batch);
sphere.draw(batch);
raypick.draw(batch);
tick.draw(batch);
batch.end();
}
We have already created a singleton instance of the dynamics world in
MyCollisionWorld . This instance is accessed here and initiated as follows:
worldInstance = MyCollisionWorld.instance;
worldInstance.init();
 
Search WWH ::




Custom Search