Making a decent explosion

Hi there!  I’ve been toying with CBEffects trying to make a good looking explosion (think of a grenade explosion) and have gotten something decent, but not really quite perfect.  

Has anyone been able to achieve this?  And, if so, can you share what settings you used to implement this?

Thanks!

Alan

I just pushed an update to the repo that includes a quick explosion I knocked up. You’ll need the most recent version, because it uses a couple of new features.

Here’s the code:

[lua]

local vent = CBE.newVent({

preset = “flame”,

title = “explosion”,

positionType = “inRadius”,

color = {{1, 1, 0}, {1, 0.5, 0}, {0.2, 0.2, 0.2}},

particleProperties = {blendMode = “add”},

x = display.contentCenterX,

y = display.contentCenterY,

emissionNum = 5,

emitDelay = 5,

perEmit = 1,

inTime = 100,

lifeTime = 0,

outTime = 600,

onCreation = function(particle)

particle:changeColor({

color = {0.1, 0.1, 0.1},

time = 600

})

end,

onUpdate = function(particle)

particle:setCBEProperty(“scaleRateX”, particle:getCBEProperty(“scaleRateX”) * 0.998)

particle:setCBEProperty(“scaleRateY”, particle:getCBEProperty(“scaleRateY”) * 0.998)

end,

physics = {

velocity = 0,

gravityY = -0.035,

angles = {0, 360},

scaleRateX = 1.05,

scaleRateY = 1.05

}

})

[/lua]

Enjoy!

  • Caleb

Wow!  That’s amazing!  Thank you so much, Caleb!

No problem :slight_smile:

  • Caleb

So, I updated to the most recent version and it is now throwing this error at me:

File: CBEffects/cbe_core/vent_core/core.lua

Line: 75

Attempt to index local ‘p’ (a nil value)

Any ideas?

Your build function isn’t returning anything. What preset (if any) are you using? What’s your build function? Are you using the explosion effect I posted?

You’ll want to check that the correct image exists, and find any other errors occurring (would be at the top, right under Corona’s initial console).

  • Caleb

I’m using the code that you posted above with the exception that I am setting a parentGroup.  Would that effect it?

Have you removed any images from the CBEffects “textures” directory?

  • Caleb

I updated CBEffects from GitHub again and it is working now (and looks great, by the way!).  Thanks again.  Sorry to be a noodge.

No worries; glad you like it :slight_smile:

  • Caleb

I just pushed an update to the repo that includes a quick explosion I knocked up. You’ll need the most recent version, because it uses a couple of new features.

Here’s the code:

[lua]

local vent = CBE.newVent({

preset = “flame”,

title = “explosion”,

positionType = “inRadius”,

color = {{1, 1, 0}, {1, 0.5, 0}, {0.2, 0.2, 0.2}},

particleProperties = {blendMode = “add”},

x = display.contentCenterX,

y = display.contentCenterY,

emissionNum = 5,

emitDelay = 5,

perEmit = 1,

inTime = 100,

lifeTime = 0,

outTime = 600,

onCreation = function(particle)

particle:changeColor({

color = {0.1, 0.1, 0.1},

time = 600

})

end,

onUpdate = function(particle)

particle:setCBEProperty(“scaleRateX”, particle:getCBEProperty(“scaleRateX”) * 0.998)

particle:setCBEProperty(“scaleRateY”, particle:getCBEProperty(“scaleRateY”) * 0.998)

end,

physics = {

velocity = 0,

gravityY = -0.035,

angles = {0, 360},

scaleRateX = 1.05,

scaleRateY = 1.05

}

})

[/lua]

Enjoy!

  • Caleb

Wow!  That’s amazing!  Thank you so much, Caleb!

No problem :slight_smile:

  • Caleb

So, I updated to the most recent version and it is now throwing this error at me:

File: CBEffects/cbe_core/vent_core/core.lua

Line: 75

Attempt to index local ‘p’ (a nil value)

Any ideas?

Your build function isn’t returning anything. What preset (if any) are you using? What’s your build function? Are you using the explosion effect I posted?

You’ll want to check that the correct image exists, and find any other errors occurring (would be at the top, right under Corona’s initial console).

  • Caleb

I’m using the code that you posted above with the exception that I am setting a parentGroup.  Would that effect it?

Have you removed any images from the CBEffects “textures” directory?

  • Caleb

I updated CBEffects from GitHub again and it is working now (and looks great, by the way!).  Thanks again.  Sorry to be a noodge.

No worries; glad you like it :slight_smile:

  • Caleb