CBResources

Hi,

for previous versions of CBEffects there were some very interesting examples included in CBResources repository on GitHub: https://github.com/Poordeveloper/corona_code/tree/master/Game.

Unfortunately they are not compatible with the latest version of CBEffects (I’m using 3.1 version).

I tried to convert some code but I have some problem with properties velX and velY:

onCreation=function(particle) particle.velX = particle.velX+(math.random(-10, 10)/25); particle.velY = particle.velY+(math.random(-10, 10)/25) -- Give a bit of random jitter end

It seems that these properties are no longer present…

Is there a way to convert older examples, contained in the file “Samples” folder, to the new versions of CBEffects?

Thanks in advance.

Regards.

-j

Alas, there is no easy way to do that. You can apply force to the particle with particle:applyParticleForce(), so you could use that for randomization.

  • C

Thanks a lot! Caleb

With your suggestions something begins to work…

Sorry, but with this beautiful library I’m still a beginner. 

Compared to the original example “Vector Mini Fireworks”, I do not see the explosions green circles and, after the first, it seems there are more contemporary “mortar” instances. 

What is wrong?

local CBE = require("CBEffects.Library") sampleVGroup=CBE.VentGroup{ { preset="sparks", title="explosion", -- The explosion vent color={{0, 255, 0}}, build=function() return display.newCircle(0, 0, 3) end, onCreation=function(particle) --particle.velX=particle.velX+(math.random(-10, 10)/25); particle.velY=particle.velY+(math.random(-10, 10)/25) -- Give a bit of random jitter particle:applyParticleForce(math.random(-10, 10)/25, math.random(-10, 10)/25 ) end, perEmit=6, positionType="atPoint", onDeath=function()end, physics={ relativeToSize=false, velocity=2, gravityY=0.05, -- Just a slight bit of gravity downwards iterateAngle=true, -- We want to go perfectly through the angles autoAngle=false, angles={ 0, 60, 120, 180, 240, 300 } } }, { preset="sparks", title="pop", -- The pop that appears when a mortar shot explodes build=function() return display.newCircle(0, 0, 10) end, color={{0, 255, 0}}, positionType="atPoint", perEmit=1, lifeSpan=300, fadeInTime=0, alpha=1, onDeath=function()end, physics={ sizeX=0.2, -- Grow X and Y sizeY=0.2, relativeToSize=false, velocity=0, gravityY=0 } }, { preset="sparks", title="mortar", -- Mortar vent color={{0, 255, 0}}, build=function() return display.newCircle(0, 0, 4) end, onDeath=function(particle, vent) sampleVGroup:translate("explosion", particle.x, particle.y) sampleVGroup:emit("explosion") -- Move and fire off the explosion sampleVGroup:translate("pop", particle.x, particle.y) sampleVGroup:emit("pop") -- And the pop end, x=512, y=668, emitDelay=500, fadeInTime=100, lifeSpan=100, lifeStart=500, positionType="atPoint", perEmit=1, physics={ angles={{60, 120}}, relativeToSize=false, velocity=15, gravityY=0.2 } } } sampleVGroup:start("mortar")

Many, many thanks!

Cheers

-j

Alas, there is no easy way to do that. You can apply force to the particle with particle:applyParticleForce(), so you could use that for randomization.

  • C

Thanks a lot! Caleb

With your suggestions something begins to work…

Sorry, but with this beautiful library I’m still a beginner. 

Compared to the original example “Vector Mini Fireworks”, I do not see the explosions green circles and, after the first, it seems there are more contemporary “mortar” instances. 

What is wrong?

local CBE = require("CBEffects.Library") sampleVGroup=CBE.VentGroup{ { preset="sparks", title="explosion", -- The explosion vent color={{0, 255, 0}}, build=function() return display.newCircle(0, 0, 3) end, onCreation=function(particle) --particle.velX=particle.velX+(math.random(-10, 10)/25); particle.velY=particle.velY+(math.random(-10, 10)/25) -- Give a bit of random jitter particle:applyParticleForce(math.random(-10, 10)/25, math.random(-10, 10)/25 ) end, perEmit=6, positionType="atPoint", onDeath=function()end, physics={ relativeToSize=false, velocity=2, gravityY=0.05, -- Just a slight bit of gravity downwards iterateAngle=true, -- We want to go perfectly through the angles autoAngle=false, angles={ 0, 60, 120, 180, 240, 300 } } }, { preset="sparks", title="pop", -- The pop that appears when a mortar shot explodes build=function() return display.newCircle(0, 0, 10) end, color={{0, 255, 0}}, positionType="atPoint", perEmit=1, lifeSpan=300, fadeInTime=0, alpha=1, onDeath=function()end, physics={ sizeX=0.2, -- Grow X and Y sizeY=0.2, relativeToSize=false, velocity=0, gravityY=0 } }, { preset="sparks", title="mortar", -- Mortar vent color={{0, 255, 0}}, build=function() return display.newCircle(0, 0, 4) end, onDeath=function(particle, vent) sampleVGroup:translate("explosion", particle.x, particle.y) sampleVGroup:emit("explosion") -- Move and fire off the explosion sampleVGroup:translate("pop", particle.x, particle.y) sampleVGroup:emit("pop") -- And the pop end, x=512, y=668, emitDelay=500, fadeInTime=100, lifeSpan=100, lifeStart=500, positionType="atPoint", perEmit=1, physics={ angles={{60, 120}}, relativeToSize=false, velocity=15, gravityY=0.2 } } } sampleVGroup:start("mortar")

Many, many thanks!

Cheers

-j