how do i make an actor come back to life after i destroy it
THINGTHING
Member Posts: 84
how do i make an actor come back to life after i destroy it
Comments
Or spawn a copy of the actor that was destroyed.
You can't take back the same actors that you destroy, but if you need that actor again, you can spawn it, or, instead of kill it, change its x and y position to take it out of the screen. When you need it again, just change it again its x and y position to take it back to the action
Otherwise, set the alpha to 0 and change attributes to off screen, then when you need it again, change the attributes to be on screen and change the alpha to 1.
// red.
SO
You could just turn it invisible temporarily? If you think you want to have it reappear later
There is an attribute called visible I think that can be turned to false.
Or change the color alpha to zero
But remember, just because something is invisible doesn't mean it can't still be collided with. To make something both invisible and unable to be collided with move it off camera, not too far though because the GameSalad engine automatically destroys objects that are moved too far off camera.
However, if you don't want to go through all the trouble of moving stuff off camera and then back on (which in my opinion is a major pain in the butt) you can just make a rule that says:
rule when self.alpha > 0
collide
that way collisions only happen if alpha is greater than 0, i.e. visible.
This prevents you from the trouble of having to move stuff off screen. The downside of course is that the collision logic is inside the thing being hidden. This can be a good or a bad thing. Depending on how many of these "hiding" actors you have. Ideally you want to have your colliders on the fewest possible things. I.e. it's better for the single player actor to collide with many walls than for many walls to collide with the single player. It's a matter of how many objects are testing for collision. Is just the single player object testing for collision vs is every single wall testing for collision? ... etc.
I think i've gone a bit off topic. You'll have to make the best call for what works for you.
- Move off screen
- destroy / respawn
- set alpha=0
- set alpha=0 w/ collision checks
once the actor overlapps or collides with whatever kills your actor reset scene