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 this, modify the init()
and render()
methods:
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 - Second Edition 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.