I am making a game in android in which enemies are randomly spawned at the top of the screen and move down. I am able to create 1 enemy that does this, but I can’t think of a good way to create many enemies that are all drawn on the same canvas. I have tried many things, and I could really use some help.
Thanks!
The easiest way to do this is to create a class
Enemy(name it whatever you like) and instantiate as many as you need using aforloop. You could use anarrayto store each instance.An example could be the following:
Then you can use an enhanced for (or for each) loop to display them wherever you’d like on your canvas.