In my tower defense game and every tile has its own mouse event listener. I am wondering, would it be better to use one event listener (MouseEvent.CLICK) and then when it runs the function, should I just use evt.target to determine what was clicked, and then run an appropriate function?
I am programming the game for web and phone and I started to notice some lag on my phone so I am trying to optimize my code. Any other tips to speed up code would help too.
target
property then. But not even that is required, since you could determine the clicked tile by calculating the index by using the mouse coordinates given by the event. That would allow you to use some light-weight components likeShape
for your tiles, or draw the tiles directly to a bitmap. \$\endgroup\$