Game Development Reference
In-Depth Information
Figure 13-18 . Be sure to set the isFlipH property for the Bagel object using .setIsFlipH() called off of the this (object)
Next, let's test all of the new sprite animation code to see if it does what we think
that it logically should do! The code is complex, at least for the primary left and right
arrow key character movement, but is quite well organized, and very logical, and I
don't see any problems with it from a logic standpoint, but testing it thoroughly using
NetBeans is the only way to find out! Let's do that next. To review the sprite image
states, refer back to Chapter 8 (Figure 8-2).
Testing the InvinciBagel Sprite Animation States: Run
Project
Now it is time to use the NetBeans Run Project work process and test the
.setImageState() method, which now gets called after the .setXYLocation() and
.setBoundaries() methods, but before the .moveInvinciBagel() method. So the logical
progression as it sits now is check keypressed, set X and Y location based on that,
check to make sure you have not gone past any boundaries, set the sprite animation
(Image) state, and then position the sprite. As you can see in Figure 13-19 , the Invin-
ciBagel character now runs realistically across the screen when you use left or right ar-
row keys.
 
 
Search WWH ::




Custom Search