Game Development Reference
In-Depth Information
You can open MyFirstPong_step3.gameproj file to follow up from this point.
Before placing this actor on the scene, add one more behavior for each rack.
Constrain its positions on the horizontal axis. This means that the racket will
move up and down but will be on a fixed horizontal position (constant value on
the X axis). To do so, use the Constraint Attribute behavior.
In the behavior library (Figure 2-14), locate the Constrain Attribute behavior and
drop it into the Actor Behavior pane below the Up rule you just created. To
select the attribute to constrain, use the Attribute Browser. Click the button with
the three dots located to the right of the value input field. Browse to Rack Player
1 Position X, as shown in Figure 2-18.
Figure 2-18. Attribute Browser
Double-click the X attribute to validate it. Assign a value of 20 for this constraint,
which will constrain the racket on a vertical axis located 20 pixels from the left of
the screen. The completed behavior is shown in Figure 2-19.
Figure 2-19. Constrain Attribute
And now you are ready to position the actor on the scene.
Adding an Actor to the Scene
So you have created the racket for player 1. Now let's position it on the scene.
Go back to the Scene Editor, and drop the actor into the scene. The location
only needs to be approximate because you have constrained the racket on the
x-axis, as shown in Figure 2-20.
 
Search WWH ::




Custom Search