Game Development Reference
In-Depth Information
The task sliderValueChanged: in Listing 5-19 is called when the user adjusts the slider at the bottom
of the screen. The slider is configured to have a value between 80 and 320, which we use as the value
as newWidth . We calculate the newHeight based on the newWidth , preserving our aspect ratio. Once
we have the new width and height for actorView , we find the X and Y values that will keep actorView
centered. Once we have all of the value values for the actorView 's new frame, we simply set it.
Actor State and Animations
Now that we have a basic set of animations, it is time to add a little life to the actors. We are going to
expand on the last examples and add two effects. The first is to make the asteroids look like they are
tumbling through space. The second is to make the spaceship rotate before moving. Both of these
techniques will update the image used to represent each actor to create the visual effect. We will
5-10 shows this next example in action.
5-11 we see the spaceship thrusting toward some point at the upper left. There are four
5-12 shows the images used to create the animation.
Figure 5-11. Adding animations and state to actors
 
Search WWH ::




Custom Search