How do I create a sprite in a random position?

Get help using Construct 2

Post » Mon Feb 20, 2017 4:09 am

Hey! I wanted to know how I can make it that at the start of the layout, a sprite is created in a random position. Like the X= a number between 10 and 200, Y=a number between 20 and 400.Thanks!
B
13
S
1
Posts: 16
Reputation: 563

Post » Mon Feb 20, 2017 4:56 am

Message: HackerBoy can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
You can add event for ~ On Start of Layout ~ and add an action to it ~ Sprite -> Set Position, it will ask for X and Y location in which fill up ~ random(starting value, maximum value) ~ it means that if your command is ~ random(10,20), it will select any random value b/w 10 to 20.. Hope it helps :)

Image : https://ufile.io/a6864
B
5
S
1
Posts: 10
Reputation: 345

Post » Mon Feb 20, 2017 11:08 am

Keep in mind that random gives a range not including the last number selected so if you want a random number between 1 and 10 it would be random(1,11)

If you need that to be an integer whole number use int(random(1,11)) and if you just want the decimals left off use floor(random(1,11)).
Banned User
B
28
S
7
G
58
Posts: 1,229
Reputation: 34,825


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 13 guests