Learn Mobile Game Development in One Day Using Gamesalad: Create Games for iOS, Android and Windows Phones and Tablets by Cross Jamie

Learn Mobile Game Development in One Day Using Gamesalad: Create Games for iOS, Android and Windows Phones and Tablets by Cross Jamie

Author:Cross, Jamie [Cross, Jamie]
Language: eng
Format: azw3
Tags: gamesalad, android game, game programming, iphone game, mobile game, video game, game development
Published: 2015-05-05T16:00:00+00:00


––––––––––––––––––––––––––––––––––––––––––

Exercise 16: Randomness

Video games often rely on random numbers to help create a more natural feeling in the game. In this exercise, you’ll use the random function to place an actor at different locations around the screen each time a button is pressed.

1Begin with the file you finished in the last exercise and create a second actor in the Actors Tab.

2Change this actor's size to 32x32 and change its color to anything other than white.

3Double-Click the white square actor from the last exercise and delete the Change Attribute Behavior from the Rule.

4Nest a Spawn Actor Behavior in this Rule and choose Actor 2 from the Actor drop-down menu.

5Open the Expression Editor for the Position X input field (right arrow).

6From the Insert Function menu, choose Random.

7Delete the text between the parenthesis “min,max” and replace it with 0,game.Display Size.Width (see Figure 13.4).

8Open the Expression Editor for the Position Y input field (up arrow).

9Add a Random function and set it up to read: random(0,game.Display Size.Height)

10Choose Scene from the Positions Relative To menu.

––––––––––––––––––––––––––––––––––––––––––



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.