Or instead you could have the enemyCreate function and add each enemy into a table, then you could just do:
for i = 1, #enemyTable do enemyTable[i]:removeSelf() --or you could add physics, movement, etc. end
In fact, here is a sample of something I worked on to get you started, I will add the file below.
The error on line 120 in enemy.lua appears to be this problem: for some reason inimigo is nil. This could be because you have them in a function, but you never called the function. Try adding local inimigo1, 2, 3, 4, etc. at the top of your enemy.lua file, and see if it works.
Hey friend, I was able to remove an enemy (trying the enemy on the left side, which is closer to the ship) but after it collides and it goes to the position it should when the shot hits it appears that message
what you mean?
ERROR: C: \ Users \ ander \ Documents \ IFPE 2017.1 \ game development \ corona \ Riverraid \ enemy.lua: 21: physics.addBody () can not be called when the world is locked and in the middle of number crunching, such As during a collision event
This error means you cannot add or remove physics bodies while a collision event is still happening. The normal solution to this is to do your actions to add or remove your object in a short timer, something like:
timer.performWithDelay(10, function() display.remove(myObject); end) -- or code to add a new enemy