Game Development Reference
In-Depth Information
use this “count up to 6” variable, the math for what we are doing would equate to
6+6=12, divided into the 60FPS pulse timing loop, means that we are slowing down
the unthrottled animation by 500% (five times, because 60/12=5). The variable declara-
tion statements at the top of the Bagel class should look like the following Java code,
and are also shown in the middle of Figure 13-8 :
int framecounter = 0 ;
int runningspeed = 6 ;
Figure 13-8 . Add int variables at top of the class for framecounter and runningspeed and set to zero in no movement
if
As you can see in Figure 13-8 , I've clicked on the framecounter variable, so it is
highlighted, and you can see its use in an initialization statement that we'll need to put
into the “no arrow keys pressed” conditional if() structure, just as we did with the an-
imator variable. The code for this if() structure is shown in Figure 13-8 , and looks like
this:
if( ! invinciBagel.isRight() &&
! invinciBagel.isLeft() &&
! invinciBagel.isDown() &&
! invinciBagel.isUp() ) {
spriteFrame.setImage(imageStates. get(0) );
animator=false;
 
 
Search WWH ::




Custom Search