Game Development Reference
In-Depth Information
And the velocity is negative:
That's it!
Figure 10-19. Get too close and the robot
flies away.
Rotating and shooting toward the player
In the final AI system, the robot turns and fires bullets toward the player if the player is within range.
Bind the Nk^kp[Odkkp class to the Nk^kp oui^kh to see this work. The robot fires bullets in one-second
intervals. Figure 10-20 illustrates what you will see when you test the project.
Figure 10-20. The robot rotates and fires bullets at the player.
You'll be happy to know that you already know 90% of the code in this class. In fact, everything from
how the object rotates to the method that fires bullets is virtually identical to the code in the Lh]uan
class. The only really new thing is the introduction of AS3.0's built-in Peian class, which is used to time
the firing of the bullets. You'll look at how the Peian class works in detail ahead.
Search Nedrilad ::

Custom Search