Object instances along the windows border

0 favourites
  • 2 posts
From the Asset Store
112 High-Quality destruction sounds for videogames
  • 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?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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).

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)