Spawning an Actor vs Changing Image
Hello,
I am adding a unit that will spawn every 10 seconds and then destroy itself after 5 seconds. I am trying to figure the best way to do this performance wise. So for the purpose of demonstration lets say this is a trap, when the trap is open, it will kill the hero, when the trap is closed hero can walk over it.
First Way:
I can place an object of a closed trap and then spawn a new object on top of the closed trap. This new object will have the image of the open trap and hero will die when he touches the open trap.
Second Way:
I can have the Trap object placed exactly where I want and change the image to open trap every 10 seconds and also set a variable "Open_Trap" to 1. Hero will die when "Open_Trap" is set to 1.
Now imagine I have about 100 traps on the screen, I am trying to figure out what would be the best way of accomplishing my trap scenario and not overburden the phone's processor.
Any help and insight is most appreciated!
Comments
Option 2 is by far the better way to go, spawn actors is much much harsher on performance than changing image. There is a thread around here called "timers are for chumps" that you can use to change the image instead of having 100 timers, which also arent too good with performance. I forgot how to code "every.... seconds" so youll have read the thread.
Thank you, i found the thread and it was very helpful.