Hi all,
after a year of life, I’ve finally found some time to revisit my shmup.
Whilst for the most part, every ‘enemy’ is individually coded, there are parts of my game where I intend to use random-spawning, to add a little edge and prevent repetitiveness.
The code I’m using to do this, is contained within a function and looks something like this:
function createEnemy() numEnemy = numEnemy +1 print(numEnemy) --enemies:toFront() enemyArray[numEnemy] = display.newSprite( imgSheet , sequenceData ) enemyArray[numEnemy]:setSequence("rotate") enemyArray[numEnemy]:play() physics.addBody ( enemyArray[numEnemy] , {density=0.0, friction=0, bounce=0}) enemyArray[numEnemy].isFixedRotation=true enemyArray[numEnemy] .myName = "enemy" startlocationX = display.contentWidth +200 enemyArray[numEnemy] .x = startlocationX startlocationY = math.random (0, display.contentHeight) enemyArray[numEnemy] .y = startlocationY transition.to ( enemyArray[numEnemy] , { time = math.random (1000, 2000), x=display.contentWidth-200, y=MyShip.y, onComplete=charge } ) group:insert(enemyArray[numEnemy] ) end
Now, what I’d like to do, instead of using sprite sheets for the explosion, is attach a particle emitter and listener to each enemy and I’m having a problem, attaching.
I’ve decided to go with Particle Candy (yes, I know) because I like the way it looks, but I can only attach a single (the same) emitter to each enemy as it’s spawned, I don’t seem to be able to ‘spawn’ a concurrent emitter.
…In order to attach my emitter (how I’m doing it now), I’m including this code at the end of the block above:
Particles.CreateFXField("Field50", 2, enemyArray[numEnemy] .x,enemyArray[numEnemy] .y , 2.5, 40, true, 18)
‘Field 50’, just means that I’ve already used 49 for another purposes.
I then attach the field using another function, like this:
Particles.GetFXField("Field50").x = enemyArray[numEnemy] .x Particles.GetFXField("Field50").y = enemyArray[numEnemy] .y
So, like I said, I’m only using a single emitter which changes to the next ‘spawnee’ when it’s born.
I would like to assign a piece of code that spawns a different emitter to each enemy. Stuck 
M