Make objects move randomly, from any point, at any time

Get help using Construct 2

Post » Tue Jan 20, 2015 8:44 pm

Hi guys been a long long time since i used C2 (probs in the R100 odd times) and alot has changes. Thinking of making a game but getting a little stumped. Im in need of a way to make an object spawn from a random location (outside of window), at a random time and to move across the screen. Any pointers? Cheers
B
11
S
2
G
2
Posts: 14
Reputation: 886

Post » Tue Jan 20, 2015 8:54 pm

I'd do it this way:

First off, give the object that you're spawning some behavior for movement. I like bullet for this case.

Every(round(random(1,10)) seconds ->
System Create Object on layer 0 at
X: round(random(ViewportLeft(0) + Sprite.Width,ViewportRight(0) - Sprite.Width))
Y: -Sprite.Height
Sprite -> Set Angle to 90

I hope this helps. This will create sprites above the play area that then move down across the viewport.
B
4
Posts: 15
Reputation: 232

Post » Tue Jan 20, 2015 10:30 pm

Sounds good, but would be looking for sprites moving in from the sides too. I guess a bit like fruit ninja. Thanks for your help though ill get cracking with the above and try and add to it
B
11
S
2
G
2
Posts: 14
Reputation: 886

Post » Wed Jan 28, 2015 10:40 pm

You can use the same logic to make objects approach from all sides. Just change the X and Y spawn positions and sprite angle.

X: ViewportRight(0) + Sprite.Width
Y: round(random(ViewportTop(0) + Sprite.Width,ViewportBottom(0) - Sprite.Width)
Sprite -> Set Angle to 180

Then you'd have them approaching from the right side of the screen.
B
4
Posts: 15
Reputation: 232

Post » Thu Jan 29, 2015 12:38 pm

MrClifford try this demo
You do not have the required permissions to view the files attached to this post.
B
255
S
39
G
15
Posts: 1,981
Reputation: 41,003


Return to How do I....?

Who is online

Users browsing this forum: Lordshiva1948 and 12 guests