How do I destroy a object once it enters then leaves layout?

0 favourites
  • 6 posts
From the Asset Store
Change the size and position of everything without calculating anything!
  • An object may have a bullet behavior or physics behavior that uses impulse to move into the layout. My problem is that I don't know how to destroy something that enters a layout and once it leaves, to destroy it.

    I realize I could use the fade behavior but for many of the objects within my game, they need to have full opacity, although I have found the fade have found the fade behavior to be useful for certain objects. Elongating the fade out time isn't useful because I will usually have objects being destroyed once outside layout to prevent performance issues.

    Of course I've thought about using the Destroy Outside Layout behavior but an object will be destroyed if it's coming from outside the layout.

    Here's a capx of what I mean: ... .capx?dl=0

    The Balls coming from the left are bullet, the balls coming from above are impulsed. Once they exit the layout, how do I destroy them?

  • Try setting the initial state of Destroy Outside Layout to disabled, and enable it later on.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The Destroy Outside Layout behavior does not have any properties.

  • how about using a booelan,

    then if that object Is on screen, set it's value to true.

    then when it is not on screen, and that boolean is true, destroy it.

  • I think I've got. I used a Number Instance Variable in place of Boolean, and enlarged the window size to show that the objects are indeed destroying once they leave the layout.

    I Used the Outside layout condition instead of On-Screen simply because my game may not have everything on screen at a time.

    Here's the update: ... .capx?dl=0

  • Hello. Its an old post but i where looking through them anyways

    You dont need any variables.

    You dont need "destroy outside layout"

    On start - disable gravity and destroy the ball and bullet C2 needs (Not need i would say, since you could place them outside the margin)

    Add a margin and set up your balls and bullet, that if they exceed the margin, destroy them.

    Spawn bullets and balls at a interval - in the margin.


    The Coding You should move the "Physics force" to a seperay event, that only apply´s when a ball is created - otherwise its gonna do it every 0.5 two times just realised now when i where looking at the image. Woops.

    The Capx

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