Game Development Reference
In-Depth Information
Figure 10-15. Positioning the pendulum
Open the Sound inventory view (click the Sounds tab next to Images tab). Click
the + sign to import a new sound. Select the file named sound4.mp3 from the
Chap4_files folder. Import the file as Sound.
You will now create the movement. To do so, you need to know the maximum
rotation of the pendulum in both directions. Set a rotation angle of a total of 20
degrees: -10 to +10. But the originating angle is 90 degrees, so the pendulum
will rotate from angle 80 to 100, back and forth. You will use the Interpolate
behavior to make the movement adependent of a Speed attribute.
Create a new rule with the following conditions:
''Attribute''''game.InMovement'' is ''true''
Then drag and drop an Interpolate behavior and change the settings.
Interpolate Attribute: Pendulum.Rotation
To: 100
Duration: game.speed
Function: Linear
Next, drag and drop a Play Sound behavior and select sound4 as the sound to
play. Leave all the other setting as the defaults.
Search WWH ::

Custom Search