Spawning object at random position outside layout?

Get help using Construct 2

Post » Thu Jul 19, 2012 11:59 pm

Hi there,

I'm making little project where I want an object to be randomly spawned outside layout but near the border, with angle that will make that object enter the layout. And so I wander if you could help me?

Thanks!
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
77
S
21
G
19
Posts: 1,932
Reputation: 17,291

Post » Fri Jul 20, 2012 12:08 am

Hey there, you could do that by using
Every X Seconds: Create Object at the position X: LayoutWidth and Y:random(0,LayotHeight);

You could add a bullet behavior to your objects to make them move or use the Move At Angle event. ;]
B
38
S
8
G
3
Posts: 439
Reputation: 6,876

Post » Fri Jul 20, 2012 12:22 am

Hey, thanks for your replay, although im not sure if this will work randomly around the whole layout. I need something that would spawn an object anywhere around the layout. Will experiment with what you said thought.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
77
S
21
G
19
Posts: 1,932
Reputation: 17,291

Post » Fri Jul 20, 2012 12:46 am

There might be an easier way, but here's one way to do it:

SpawnOutsideLayout.capx (r99)

It's basically what sheepy said, but if you want to spawn from all directions you first need to pick an edge to spawn from.
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Fri Jul 20, 2012 2:23 am

Hey, thanks for your help. I took sheepy advice and expanded it and it works perfectly :)
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
77
S
21
G
19
Posts: 1,932
Reputation: 17,291

Post » Sun May 05, 2013 8:00 pm

Thanks! This was exactly what I was looking for!
B
8
S
2
G
2
Posts: 11
Reputation: 1,756

Post » Mon Aug 08, 2016 2:00 pm

@Nimtrix
Can you put again the capx ?
B
10
S
3
Posts: 272
Reputation: 1,360


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 11 guests