Game Development Reference
In-Depth Information
Finally, make the following changes to the update() and render() methods in the
same class to let each carrot update correctly as well as render the goal and the
carrot game objects in the right order on the screen, as follows:
public void update (float deltaTime) {
// Feathers
for (Feather feather : feathers)
feather.update(deltaTime);
for (Carrot carrot : carrots)
carrot. Update(deltaTime);
// Clouds
clouds.update(deltaTime);
}
public void render (SpriteBatch batch) {
// Draw Mountains
mountains.render(batch);
// Draw Goal
goal.render(batch);
// Draw Rocks
for (Rock rock : rocks)
rock.render(batch);
for (Feather feather : feathers)
feather.render(batch);
// Draw Carrots
for (Carrot carrot : carrots)
carrot.render(batch);
// Draw Player Character
bunnyHead.render(batch);
}
You may want to run the game now and verify that the goal game object is visible at
the end of the level. However, nothing will happen when the player character passes
it. We will address the implementation details for the event handling and physics
simulation next.
 
Search WWH ::




Custom Search