Completing the level loader

Now that we have implemented all the game objects of Canyon Bunny, we can complete the level loader.

First, add the following import lines to Level:

import com.packtpub.libgdx.canyonbunny.game.objects.BunnyHead;
import com.packtpub.libgdx.canyonbunny.game.objects.Feather;
import com.packtpub.libgdx.canyonbunny.game.objects.GoldCoin;

Additionally, add these three member variables to the same class:

public BunnyHead bunnyHead;
public Array<GoldCoin> goldcoins;
public Array<Feather> feathers;

After that, modify the two methods init() and render() as follows:

private void init (String filename) {
  // player character
  bunnyHead = null;
  // objects
  rocks = new Array<Rock>();
  goldcoins = new Array<GoldCoin>();
 feathers = new Array<Feather>(); ...

Get Learning Libgdx Game Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.