-
Book Overview & Buying
-
Table Of Contents
Android Game Programming By Example
By :
First, let's add some methods in the Player class that our input controller will be able to call, then manipulate the variables that the Player class's update method uses to move around.
We already played with the isPressingRight variable, and also have an isPressingLeft variable. Furthermore, we want to be able to jump. If you take a look at the Player class's update method, we already have the code to handle these situations. We just need the player to be able to initiate the movements via touches to the screen.
Our previous button layout design and the code we have written so far, suggests a method for going left, a method for going right, and a method for jumping.
You will also note that we pass a copy of SoundManager into the startJump method, which allows us to play a neat retro jumping sound, if the jump attempt is successful. Add these three new methods to the Player class:
public void setPressingRight(boolean isPressingRight) {
this.isPressingRight = isPressingRight...
Change the font size
Change margin width
Change background colour