Game Development Reference
In-Depth Information
There are a few tips you need to know about the Expression Editor:
1. .. is used to show more than one attribute.
Example: (actor.position.X)..(actor.position.Y)
2. “text” is used to display text.
Example: “X Position: “..(actor.position.X)
3. \” is used to insert a double quote in the text within a double
quoted text.
Example: “This is a quote \” in a text”
4. \32 is used to insert a space in the text within a double quoted
text.
Example: “This\32is\32a\32space”
5. \n is used to start a new line in the text within a double quoted
text.
Example: “This add \n a new line”
Let's go back to the rackets to enable them to spawn the ball. The ball will be
spawned when the space bar is pressed. And guess what? You'll use a rule.
Open the Rack Player 1 in the Actor Editor. Create a new rule and name it
Serving. The condition is when the Actor receives event and when the space key
is down.
You also need to check if it is Player 1's turn to serve. To do so, use the
attribute that you previously created, P1Serving. If P1Serving is true and the
space bar is pressed, then Rack Player 1 will spawn the ball.
Add a new condition in the Serving rule by clicking the + sign. The condition will
be if attribute game.P1Serving is true.
Now, add a Spawn Actor behavior in the behavior area of the Serving rule.
Change the actor to Ball and the horizontal position to 16. This will spawn the
ball just in front of the racket.
The Serving rule should look similar to Figure 2-28.
 
Search WWH ::




Custom Search