SSK2: Particles always on top.

Hi,

In my current game I have setup display groups using the SSK2 Quick layers function like thus:

layers = quickLayers ( sceneGroup, "background", "playground", "bomblayer", "aliens", "foreground", "hud" )

What I have found though is that when using an emitter for a particle effect…

splosion = ssk.pex.loadPD2 (layers.bomblayer, spX, spY, "splosion.json" ) 

you would expect that an explosion that is triggered on the ‘bomb layer’ display group  would be partially hidden by objects that are in the ‘aliens’, ‘foreground’ and ‘hud’ groups but they’re not.  Regardless of which layer I place the emitter the particles are always on top of everything.

I have also tried using regular display groups as opposed to the SSK2 QuickLayers but that made no difference,

require "ssk2.loadSSK" \_G.ssk.init({enableAutoListeners=true}) local newRect = ssk.display.newRect local quickLayers = ssk.display.quickLayers --local layers = quickLayers ( sceneGroup, "background", "playground", "bomblayer", "aliens", "foreground", "hud" ) local background=display.newGroup() local foreground=display.newGroup() local back = newRect( background, centerX, centerY, { w = fullw, h = fullh, fill = \_DARKGREY\_ } ) local fore = newRect( foreground, centerX, centerY, { w = fullw, h = fullh, fill = \_DARKGREY\_ } ) local explosion = ssk.pex.loadPD2 ( background, centerX, centerY, "greenbarrier.json" ) 

so is this a Corona level thing or an issue with the SSK pex loader in the way it displays the particles? 

There is a bug in the pex code, and fixing it does resolve  the problem you’re seeing.  

The fix will be in:  2017.009

If you want to add the changes to your current version, then edit pex.lua and replace the pex() function with this:

-- == -- Common emitter builder, used by all other variants below. -- == local function pex( group, x, y, data, params ) params = params or {} local group = group or display.currentStage local overrides = overrides or {} local fixNumbers = params.fixNumbers or false -- Strip for override later --params.fixNumbers = nil -- Apply overrides for k,v in pairs(params) do data[k] = v end -- If 'fixNumbers' requested, apply if( fixNumbers ) then local val for k,v in pairs(data) do val = tonumber(v) if( val ~= nil ) then data[k] = val print(val) end end end --table.dumpu(data) local emitter = display.newEmitter( data ) emitter.x = x emitter.y = y group:insert(emitter) return emitter, data end

Just an FYI, there are two alternatives available for particles you might be able to use if this is a showstopper:

Unfortunately, there is no editor for these.  I considered making one once, but never found the time.

Ed, you’re a legend.  I’ve edited the pex.lua with the updated function and it’s worked like a charm both in my game and the example I posted.  I was thinking about going back to Particle Candy as I know that worked as it doesn’t use the corona emitter functions, but although it has some really nice features it can be a PITA to use.

There is a bug in the pex code, and fixing it does resolve  the problem you’re seeing.  

The fix will be in:  2017.009

If you want to add the changes to your current version, then edit pex.lua and replace the pex() function with this:

-- == -- Common emitter builder, used by all other variants below. -- == local function pex( group, x, y, data, params ) params = params or {} local group = group or display.currentStage local overrides = overrides or {} local fixNumbers = params.fixNumbers or false -- Strip for override later --params.fixNumbers = nil -- Apply overrides for k,v in pairs(params) do data[k] = v end -- If 'fixNumbers' requested, apply if( fixNumbers ) then local val for k,v in pairs(data) do val = tonumber(v) if( val ~= nil ) then data[k] = val print(val) end end end --table.dumpu(data) local emitter = display.newEmitter( data ) emitter.x = x emitter.y = y group:insert(emitter) return emitter, data end

Just an FYI, there are two alternatives available for particles you might be able to use if this is a showstopper:

Unfortunately, there is no editor for these.  I considered making one once, but never found the time.

Ed, you’re a legend.  I’ve edited the pex.lua with the updated function and it’s worked like a charm both in my game and the example I posted.  I was thinking about going back to Particle Candy as I know that worked as it doesn’t use the corona emitter functions, but although it has some really nice features it can be a PITA to use.