Can I destroy particles when game is over?

mhedgesmhedges Raised on VCSMember Posts: 634
edited September 2014 in Working with GS (Mac)

Hello -

I am working on a project in which there are random backgrounds in a game, just to keep things lively. One of the backgrounds uses particles which lazily move about the screen, hence they have a long Lifetime.

The problem is as follows: if the current game in which the random background has the "lazy particles" is over, and you tap on the screen to restart (within a span of up to 30 seconds), the "lazy particles" continue to survive in the new game until the end of their Lifetime.

Is there a way to destroy or eliminate said particles as a result of starting a new game?

Thanks, regards.

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    Hi @mhedges A way to do this is make a new scene with the same background (so a rule at the side of the screen to match the random one chosen in the game screen) and any other buttons etc, the same; when game is over, go to this new screen... then after 0.1 seconds, go back to your game screen.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • HopscotchHopscotch Member, PRO Posts: 2,782

    @mhedges, you can also destroy the actor containing the particle spawner and spawn a new one when needed.

    Destroying the actor containing the particle spawner, will remove all particles on the scene.

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    Hey @Hopscotch, why didn't I think of that! Excellent solution, i think (and better than mine...) :smile:

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • mhedgesmhedges Raised on VCS Member Posts: 634

    @gyroscope, @Hopscotch - Thanks for the reply, gents. I may have done it wrong, as the problem still persists. I created a background actor prototype, which is spawned at the beginning of the game and destroyed at the end, and spawns upon starting a new game, but the particles with Lifespan left survived the events. Let me see if I can work it out.

  • mhedgesmhedges Raised on VCS Member Posts: 634

    Still puzzling. I went back to ensure the background actor is destroyed by setting the timer to "after 1 second, destroy", while the game goes to the game over scene after 3 seconds. So, the actor is destroyed, later spawned at the start of a new game, but the particles with remaining Lifetime survived. BTW, If it helps, the Lifespan goes up to 30 seconds, as the particles can take that long to cross the screen.

  • mhedgesmhedges Raised on VCS Member Posts: 634

    @Hopscotch said:
    mhedges, you can also destroy the actor containing the particle spawner and spawn a new one when needed.

    Destroying the actor containing the particle spawner, will remove all particles on the scene.

    Hmm, let me make sure I read right:

    Do you mean I have to:
    1. destroy the background actor, which has the Particle behaviour, or
    2. destroy the event handler, which spawns the background actor?

    Thanks!

  • mhedgesmhedges Raised on VCS Member Posts: 634

    Solved-ish.

    To work around the issue, I just created another background actor to handle specifically that background type (the particles). What will keep me up tonight is thinking if the particles were really destroyed... Well, not really; I'll sleep like a log. :smiley:

    Thanks for the replies, though; much appreciated!

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    Hi, as long as you destroy the actor that has the Particles behaviour in it, then you should be OK... if not, you might have another Particles behaviour somewhere else as well...

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • Spalding004Spalding004 Member, BASIC Posts: 89

    You could also just wrap the particles behavior in rule where gameOver=False then particles.

Sign In or Register to comment.