Game Development Reference
In-Depth Information
Defining the Game Logic with Rules and
Behaviors
Now it's time to define the game logic. You will re-use rules and behaviors that
have been covered in the previous chapters. This is an excellent opportunity to
review the Timer behavior and the accelerometer usage.
Ball Rules and Behaviors
In order to move the ball, you will use the accelerometer as you did in Chapter 4.
You will implement the four directions. Remember that if you were to publish
this game, you would need to implement the auto-rotate in order to keep valid
movements.
Open the Ball actor in the Actor Editor. Create a new group and name it
''accelerometer.''
Create a new rule and name it ''up.'' The condition of the rule is
''attribute''''device.Accelerometer.X''''<''''-0.1.'' Then drag and drop an
Accelerate behavior and change the settings to:
Direction: 270
Relative to: actor
Acceleration: max(100, min( 1400, abs(
device.Accelerometer.X * 1000)
The rule is shown in Figure 8-2.
Figure 8-2. Up Accelerometer rule
 
Search WWH ::




Custom Search