Game Development Reference
In-Depth Information
Figure 13-2 . Add a conditional if() statement that checks for no movement, and sets the wait sprite image state (zero)
Next let's start to implement some of the other character image cels to try and get
our character animating!
The InvinciBagel Run State: If KeyPressed Set im-
ageState(1 & 2)
As you have seen in Chapter 8 , I am going to try and achieve an animated run state for
the character using only two sprite cels, imageState(1) and imageState(2). This is about
as optimized as you can get, both from an Image assets standpoint, as well as from a
coding standpoint, as you are about to see. This is especially true given that you can't
animate anything such as a run cycle using a single image state. That said, we are go-
ing to create a lot of very realistic animation during this chapter by using single cel,
well-designed, sprite states, in combination with the sprite motion code that we put into
place in Chapter 12 . The if(invinciBagel.isRight()) and
if(invinciBagel.isLeft()) statement constructs will initially be quite easy
and straightforward, but these will grow far more complex as we add refining features
during the course of this chapter. We will put the foundation into place for these first,
then add the up and down conditional if() statements, and then later, we will refine the
right and left KeyEvent handling. Inside of the if() constructs for the left and right ar-
row key (and A and D key movement), we will use the same chained method call that
we used in the first (impatiently waiting state) if() construct, only here we will call the
 
Search WWH ::




Custom Search