Can I destroy particles when game is over?
mhedges
Raised on VCSMember Posts: 634
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
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
@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.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
Hey @Hopscotch, why didn't I think of that! Excellent solution, i think (and better than mine...)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
@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.
My Blog / App Store / Google Play
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.
My Blog / App Store / Google Play
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!
My Blog / App Store / Google Play
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.
Thanks for the replies, though; much appreciated!
My Blog / App Store / Google Play
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
You could also just wrap the particles behavior in rule where gameOver=False then particles.