Object instances along the windows border

Get help using Construct 2

Post » Fri Nov 01, 2013 6:34 am

I need to generate instances of ball at random time along the borders of the window and then make them move towards opposite border of the window.

How can I do this in Construct 2?
B
4
S
1
Posts: 9
Reputation: 345

Post » Fri Nov 01, 2013 6:43 am

On start of layout
Timer 'create ball'
.. start Timer 'once, random(1,5)'

On timer finished 'create ball'
.. create object ball at (X= choose(0, windowWidth), y= random(0,windowHeigth)
.. ball set angleOfMotion to scrollX, scrollY
.. start Timer create Ball 'once, random(1,5)'

This might work, or at least give you an idea how to do it. It will only spawn balls to the left or right side of the screen, if you want them to spawn at top and bottom too it's the same method with one extra condition added.

So you'll need to have timer behavior on your level (on some invisible object or something like that) and the ball object needs bullet behavior. Every time the timer finishes, a ball will be spawned at the edge and it's Y coordinate will be randomed along the edge. Then we set the motion towards center of the screen (which is the scrollX, scrollY expression).
B
24
S
9
G
7
Posts: 756
Reputation: 7,302


Return to How do I....?

Who is online

Users browsing this forum: Norafaithrainbow and 26 guests