Particle Candy Q - Trying to set my emitter to remain on multiple instances of my bullet object. -- video --

Happy to report that I’ve got it working! :smiley:
I had to reformat my overall ‘shootBullet’ function.

If anyone is interested, this is the final product - I’ll be cleaning it up a bit, but nevertheless here it is:
[lua]
local function shootBullet()
 
  PlayerBulletCount = PlayerBulletCount + 1
  print(“PlayerBulletCount increased by 1”)
    
  local pt = mathapi.rotateAboutPoint( {x=user_turret.x,y=user_turret.y-60}, user_turret, user_turret.rotation - 90 )
 
 
  local emitterName   = “E”   … (#BEmitters + 1) – This will concatenate the current number of enemy tanks to the end of the string, resulting in E1 for the first, E2 for the second, etc.
     
  local Emitter = display.newGroup()
  local bullet = display.newGroup()
    
  --bullet attributes    
  bullet.body = loader:createSpriteFromSHDocument(“Weapon5ex”, “GameFX”, “LevelAssets.pshs”);
  bullet.body.x = pt.x; bullet.body.y = pt.y;
  physics.addBody( bullet.body , “dynamic”, { friction= 0, bounce= 1.0, density= .6, radius= 7, filter = bulletCollisionFilter} );
  bullet.body:scale(.6,.6);
    
  bullet.body.class = “bullet”
  bullet.body.isBullet = true
    
  bullet.body.rotation = user_turret.rotation + 90
  bullet.body:applyForce( pt.x - user_turret.x, pt.y - user_turret.y, user_turret.x, user_turret.y )

  bullet.body.class = “EnemyTank”
 
  – Bullet Emitter
  Particles.CreateEmitter(emitterName, 0, 0, 0, true, true) – Uses the base name (generated dynamically with each tank)
  bullet.emitter = Particles.GetEmitter(emitterName)
        
    Particles.CreateParticleType (“BulletSTrail”,
        {
        imagePath           = “gfx/smoke01.png”,
        imageWidth            = 12,    
        imageHeight            = 12,    
        directionVariation    = 45,
        velocityVariation    = 50,
        rotationVariation    = 360,
        rotationChange        = 30,
        useEmitterRotation    = false,
        alphaStart            = 0.5,
        fadeInSpeed            = 1.5,
        fadeOutSpeed        = .5,
        fadeOutDelay        = 100,
        scaleStart            = 0.5,
        scaleVariation        = 0.5,
        scaleInSpeed        = 1.0,
        emissionShape        = 1,
        emissionRadius        = 1,
        killOutsideScreen    = true,
        lifeTime            = 200,
        blendMode            = “subtract”,
        } )
    
    Particles.AttachParticleType(emitterName , “BulletSTrail”,  32, 99999,0)
    
    local R = 153
    local G = 153
    local B = 153
    Particles.SetParticleProperty(“BulletSTrail”, “colorStart”, {R,G,B})

    local function attachBEmitters()
     
        if BEmitters then
            
            print( "Number of Emitters: " … tostring( #BEmitters ) )

            if #BEmitters~=0 then
    
                Particles.SetEmitterTarget( emitterName, bullet.body, true, 0, 0, 0 )
                Particles.StartEmitter(emitterName)

            end
        end

      return Emitter
   
    end

    for i=1,1 do
        BEmitters[#BEmitters + 1] = attachBEmitters()
    end
    timer.performWithDelay(10, attachBEmitters)

   local onPlayerBulletCollision = function(self, event)
       
    local parentObject = PlayerBullets[self._index]       
 
        if event.phase == “began” then
        Particles.StopEmitter(“PBEmitter”)
        Particles.StopEmitter(“ETBEmitter”)
        Particles.StopEmitter(emitterName)
        display.remove(bullet.emitter)
        --table.remove(BEmitters)
         print(“bullet hit something”)
            --[[
            if event.other.class == “Player” or event.other.class == “Uturret”
            then
                print(" Hit PlayerTank “)
                bullet1:removeSelf()
                print(” Projectile Removed ")
                removePlayer()
        end–]]   

            if event.other.class == “bullet”  
            then
                display.remove(self)
                print(" two bullets collided … bullets removed “)
            end
                
        elseif  event.phase == “ended”  then
            
            print(“PlayerBulletCount decreased by 1”)
            PlayerBulletCount = PlayerBulletCount - 1
            
            print(“EnemyBulletCount increased by 1”)
            EnemyBulletCount = EnemyBulletCount - 1
            
            display.remove(self)
            print(” Projectile Removed ")
    
        
        end

    return true
    
  end
  bullet.body.collision = onPlayerBulletCollision
  bullet.body:addEventListener(“collision”, bullet.body)
 
 
  bullet:insert( bullet.body )
  --bullet:insert( bullet.emitter )
  camera:add(bullet, 6, false)
 
  table.insert(PlayerBullets, bullet) – This adds the tank to the PlayerBullets table and increments the #PlayerBullets by one
 
  bullet.body._index = table.indexOf(PlayerBullets, bullet)
  bullet.emitter._index = bullet.body._index

  return bullet
 
end

[/lua]

Cheers!

-Saer