Game Development Reference
In-Depth Information
bounds.set(0, 0, dimension.x, dimension.y);
collected = false;
}
public void render (SpriteBatch batch) {
if (collected) return;
TextureRegion reg = null;
reg = regFeather;
batch.draw(reg.getTexture(), position.x, position.y,
origin.x, origin.y, dimension.x, dimension.y, scale.x, scale.y,
rotation, reg.getRegionX(), reg.getRegionY(),
reg.getRegionWidth(), reg.getRegionHeight(), false, false);
}
public int getScore() {
return 250;
}
}
Obviously, this code is almost similar to the code of the gold coin. The only
difference between them is the image used and that the getScore() method
returns a slightly higher score.
Creating the bunny head object
The bunny head or player's character is the most complex game object that we will
create in this project. It consists of only one image, but involves quite a lot of code to
enable jumping and falling as well as handling the feather power-up effect.
Create a new file for the BunnyHead class and add the following code:
package com.packtpub.libgdx.canyonbunny.game.objects;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
 
Search WWH ::




Custom Search