How to create clones in gamelab

Greetings @broxscar,

I don’t know exactly what your problem is, but it looks your enemy spawning and assigning enemy properties seems to be inefficient when you say “the previous enemy only does it’s last command”. You can easily spawn enemies and assign them properties (health, etc.) by following these steps.

  1. Set up an array (an array is just multiple datas in 1 variable, sort of like a list of data in one variable)
var enemies = [];
  1. In the block where you spawn your enemies in, you should add that enemy to the “enemies” list like this:
if (ec < el) {
      enem = createSprite(200, 200);
      enem.setAnimation("Enemy");
      enem.setCollider("rectangle", 0, 0, 50, 50);  // This line seems a little unnecessary btw
      ec = ec + 1;
      enemies.push(enem);
}
  1. Now, we can go through and check the list constantly by using a for loop in your draw loop:
for (var e = enemies.length-1; e > -1; e--) { // This goes through the whole enemy array and checks for properties forever
  
}
  1. Now, to assign the properties to your enemies you need to get said enemy in the first place
for (var e = enemies.length-1; e > -1; e--) {
    var ee = enemies[e]; // This variable stores the enemy itself
    drawSprite(ee); // Note: This is different from drawSprites as it's not plural and is needed for the enemy to appear
}
  1. You can assign any properties you want like collide, visibility, health, etc!
for (var e = enemies.length-1; e > -1; e--) {
    var ee = enemies[e]; 
    drawSprite(ee); 
    ee.collide(edges)
    ee.health = 100;
    if (ee.health <= 0) {
      ee.destroy();
      enemies.splice(e, 1) //If you wanna know what this does, this simply just removes the enemy from the array
    }

I didn’t test this out on your project yet because I don’t know what properties you want, but you can ask more questions if needed and I’ll try to answer them!