Game Development Reference
In-Depth Information
The hasFeatherPowerup and timeLeftFeatherPowerup variables describe
whether the player has collected the feather power-up or not and how much time
the effect will last. The power-up effect can be enabled and disabled by calling
setFeatherPowerup() . The hasFeatherPowerup() method is used as a combined test
to find out whether the power-up has been collected and if the effect is still lasting.
The render() method will tint the image of the player character orange if the feather
power-up has been collected. The viewing direction viewDirection is used to
decide whether the image needs to be flipped on the x axis.
Updating the rock object
Last but not least, change the setLength() method of Rock to the
following listings:
public void setLength (int length) {
this.length = length;
// Update bounding box for collision detection
bounds.set(0, 0, dimension.x * length, dimension.y);
}
This will make sure that the size of the bounding box is adjusted whenever the
length of a rock is changed.
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;
 
Search WWH ::




Custom Search