Game Development Reference
In-Depth Information
Next, remove the code below the two comments Select next sprite and Toggle
camera follow in the keyUp() method of WorldController so that the resulting
method looks like this:
@Override
public boolean keyUp (int keycode) {
// Reset game world
if (keycode == Keys.R) {
init();
Gdx.app.debug(TAG, "Game world resetted");
}
return false;
}
Add the following two imports to WorldController :
import com.packtpub.libgdx.canyonbunny.game.objects.Rock;
import com.packtpub.libgdx.canyonbunny.util.Constants;
Next, add the following code to WorldController :
public Level level;
public int lives;
public int score;
private void initLevel () {
score = 0;
level = new Level(Constants.LEVEL_01);
}
Change the code in the init() method of WorldController :
private void init () {
Gdx.input.setInputProcessor(this);
cameraHelper = new CameraHelper();
lives = Constants.LIVES_START;
initLevel();
}
Finally, remove the call to the deleted updateTestObjects() method in update() .
We have now removed all of the old code and added level loading to the controller.
There are also two variables, score and lives , that count the player's score and the
player's extra lives.
 
Search WWH ::




Custom Search