CBEffects

30 Free particle textures I made for use as particles:

http://bit.ly/Vk294K

Enjoy, and thanks to everyone! [import]uid: 147322 topic_id: 33493 reply_id: 136444[/import]

See if that helps. [import]uid: 147322 topic_id: 33493 reply_id: 136575[/import]

Link don’t work for me

[import]uid: 147488 topic_id: 33493 reply_id: 136445[/import]

30 Free particle textures I made for use as particles:

http://bit.ly/Vk294K

Enjoy, and thanks to everyone! [import]uid: 147322 topic_id: 33493 reply_id: 136444[/import]

See if that helps. [import]uid: 147322 topic_id: 33493 reply_id: 136575[/import]

Hey Caleb,

First time I’ve checked this library - wow, more sophisticated then I could ever imagine.

I’m having troubles however getting the effect to stop.

Essentially there’s a moving physics ball and when the player hits it I want to have a short shower of confetti.

My code so far is:

[code]
local partTimer

toggleWin(“Win”)
local event = {
name = “finished”,
type = “full”,
healthPercent = 100
}

Runtime:dispatchEvent(event)
ball:setLinearVelocity( 0, 0 )

–ball.angularVelocity = 0
applyBody( ball, { bounce=.8, linearDamping=0, angularDamping=0, radius=radius/2 } )
ball:applyLinearImpulse(0,3.5, ball.x, ball.y)

local function clamp(a, limits, limitl) – Build a simple clamp function
if a<=limitl and a>=limits then
return a
elseif a>limitl then
return limitl
elseif a return limits
end
end

local TargetVentGroup=CBE.VentGroup({ – Create the target vent for the collision field
{
preset=“confetti”,
perEmit=10, – High perEmit, may make it laggy, but I’ve done it so the light effect is more visible
lifeSpan = 500,
lifeStart = 250,
onCreation=function(p, v)
transition.cancel(p.trans) – Cancel the life transition - so that the transition isn’t battling with the collision field for alpha changing
print(p.lifeSpan + v.lifeStart)
p.trans = timer.performWithDelay(p.lifeSpan + v.lifeStart, p.kill) – Create the new “transition”, really just a timer that kills it at the end
end,
alpha=0, – We don’t want a “flash” effect
startAlpha=0
}
--{} could create additional vents here
})

TargetVentGroup:startMaster() – Start it

local FieldGroup=CBE.FieldGroup({ – Create the field group itself
{
targetVent=TargetVentGroup:get(“confetti”), – Use the confetti vent from “TargetVentGroup”
title=“light”, – Title it
radius=display.contentWidth, – Make sure that it is a huge collision field so that particles are always colliding
onCollision=function(p, f)
p.alpha=clamp(1/lengthOf(p.x, p.y, f.x, f.y)*100, 0, 1) – The backbone of the light - a function that sets alpha according to position
end
}
})

FieldGroup:startMaster() – Start the field

timer.performWithDelay(800,
function()
transition.to(FieldGroup:get(“light”), {x=math.random(1024), y=math.random(768), time=500})
end, 0) – Transition the field to different positions]]–

timer.performWithDelay(1000,
function()
TargetVentGroup:stopMaster()
FieldGroup:stopMaster()
TargetVentGroup:destroyMaster()
FieldGroup:destroyMaster()
end,1)

[/code]

However I’m getting the following error:

CBEffects/Library.lua:224: attempt to index field ‘particle’ (a nil value)
message
stack traceback:

Which seems to suggest p.kill() is being called after I’ve destroyed the particleVent. I presume it’s being called because of the p.trans call when creating the vent, so I’m guessing that I’m not destorying things properly - i.e in my timer up above.

Any advice would be much appreciated. Awesome library BTW. [import]uid: 33275 topic_id: 33493 reply_id: 140211[/import]

@SegaBoy:
Glad you like it :slight_smile:

The code you are using is a sample - if you want a normal confetti effect, just use
[lua]local TargetVentGroup=CBE.VentGroup{
{
preset=“confetti”
–And then, of course, set all of the parameters according to whatever you need
}
}

…[/lua]
I made that sample to show alpha effects - without the canceling of the transition and starting of the timer, it should work.

Caleb [import]uid: 147322 topic_id: 33493 reply_id: 140242[/import]

Hey Caleb - thanks for the answer.

I actually got the above code to work by commenting out the following calls in my timer. I thought that I would have to be responsible for stopiing and destroying the master vent, but that seemed to be causing the problem.

timer.cancel(partTimer)  
--TargetVentGroup:clean("confetti")  
TargetVentGroup:stop("confetti")  
--TargetVentGroup:stopMaster()  
FieldGroup:stop("light")  
--TargetVentGroup:destroyMaster()  
FieldGroup:destroyMaster()  

Think I’ll go with what you posted up above, I was probably chewing more then I could swallow to begin with :slight_smile: [import]uid: 33275 topic_id: 33493 reply_id: 140243[/import]

Hey Caleb,

First time I’ve checked this library - wow, more sophisticated then I could ever imagine.

I’m having troubles however getting the effect to stop.

Essentially there’s a moving physics ball and when the player hits it I want to have a short shower of confetti.

My code so far is:

[code]
local partTimer

toggleWin(“Win”)
local event = {
name = “finished”,
type = “full”,
healthPercent = 100
}

Runtime:dispatchEvent(event)
ball:setLinearVelocity( 0, 0 )

–ball.angularVelocity = 0
applyBody( ball, { bounce=.8, linearDamping=0, angularDamping=0, radius=radius/2 } )
ball:applyLinearImpulse(0,3.5, ball.x, ball.y)

local function clamp(a, limits, limitl) – Build a simple clamp function
if a<=limitl and a>=limits then
return a
elseif a>limitl then
return limitl
elseif a return limits
end
end

local TargetVentGroup=CBE.VentGroup({ – Create the target vent for the collision field
{
preset=“confetti”,
perEmit=10, – High perEmit, may make it laggy, but I’ve done it so the light effect is more visible
lifeSpan = 500,
lifeStart = 250,
onCreation=function(p, v)
transition.cancel(p.trans) – Cancel the life transition - so that the transition isn’t battling with the collision field for alpha changing
print(p.lifeSpan + v.lifeStart)
p.trans = timer.performWithDelay(p.lifeSpan + v.lifeStart, p.kill) – Create the new “transition”, really just a timer that kills it at the end
end,
alpha=0, – We don’t want a “flash” effect
startAlpha=0
}
--{} could create additional vents here
})

TargetVentGroup:startMaster() – Start it

local FieldGroup=CBE.FieldGroup({ – Create the field group itself
{
targetVent=TargetVentGroup:get(“confetti”), – Use the confetti vent from “TargetVentGroup”
title=“light”, – Title it
radius=display.contentWidth, – Make sure that it is a huge collision field so that particles are always colliding
onCollision=function(p, f)
p.alpha=clamp(1/lengthOf(p.x, p.y, f.x, f.y)*100, 0, 1) – The backbone of the light - a function that sets alpha according to position
end
}
})

FieldGroup:startMaster() – Start the field

timer.performWithDelay(800,
function()
transition.to(FieldGroup:get(“light”), {x=math.random(1024), y=math.random(768), time=500})
end, 0) – Transition the field to different positions]]–

timer.performWithDelay(1000,
function()
TargetVentGroup:stopMaster()
FieldGroup:stopMaster()
TargetVentGroup:destroyMaster()
FieldGroup:destroyMaster()
end,1)

[/code]

However I’m getting the following error:

CBEffects/Library.lua:224: attempt to index field ‘particle’ (a nil value)
message
stack traceback:

Which seems to suggest p.kill() is being called after I’ve destroyed the particleVent. I presume it’s being called because of the p.trans call when creating the vent, so I’m guessing that I’m not destorying things properly - i.e in my timer up above.

Any advice would be much appreciated. Awesome library BTW. [import]uid: 33275 topic_id: 33493 reply_id: 140211[/import]

@SegaBoy:
Glad you like it :slight_smile:

The code you are using is a sample - if you want a normal confetti effect, just use
[lua]local TargetVentGroup=CBE.VentGroup{
{
preset=“confetti”
–And then, of course, set all of the parameters according to whatever you need
}
}

…[/lua]
I made that sample to show alpha effects - without the canceling of the transition and starting of the timer, it should work.

Caleb [import]uid: 147322 topic_id: 33493 reply_id: 140242[/import]

Hey Caleb - thanks for the answer.

I actually got the above code to work by commenting out the following calls in my timer. I thought that I would have to be responsible for stopiing and destroying the master vent, but that seemed to be causing the problem.

timer.cancel(partTimer)  
--TargetVentGroup:clean("confetti")  
TargetVentGroup:stop("confetti")  
--TargetVentGroup:stopMaster()  
FieldGroup:stop("light")  
--TargetVentGroup:destroyMaster()  
FieldGroup:destroyMaster()  

Think I’ll go with what you posted up above, I was probably chewing more then I could swallow to begin with :slight_smile: [import]uid: 33275 topic_id: 33493 reply_id: 140243[/import]

Hey Caleb, I’m having a few problems and hope you can help.

So I used your code up above and it all works nicely; however I’m trying to stop the Vent in scene:exitScene with TargetVentGroup:stop() and getting the following error:

CBEffects/Library.lua:299: attempt to concatenate local ‘t’ (a nil value)

I tried to use stopMaster(), which seemed to work perfectly however I noticed that when transitioning to the next scene p.kill is still being called. I put a print message in that function and noticed it still being called.

Am I stopping the vent correctly using this method or is there another way?

Many thanks, [import]uid: 33275 topic_id: 33493 reply_id: 141178[/import]

OK so I need to pass a table in if I use .stop() - however do you know why I’m having the issue with stopMaster()?

Also what parameter do I pass in to stop()?

Cheers, [import]uid: 33275 topic_id: 33493 reply_id: 141179[/import]

Scrub all that - I seem to have got it working - apologies :slight_smile: [import]uid: 33275 topic_id: 33493 reply_id: 141180[/import]

Hey!

Glad you got it working - just to clarify, I’ll post this.

When changing scenes, you should use the destroyMaster command. It completely nils out the VentGroup.
[lua]VentGroup:destroyMaster()
VentGroup=nil[/lua]
Stopping a vent simply stops the particles coming from it - things will continue to occur until the last round of particles emitted from it die.

The commands “stop”, “start”, “emit”, “destroy”, “get”, and “clean” commands take strings as arguments - the title of the vent(s) that you want to stop, start, emit, destroy, get, or clean. They can take as many arguments as there are vents in the VentGroup:
[lua]VentGroup:start(“MyVent1”, “MyVent2”, “MyVent3”)

VentGroup:start(“MyVent1”)[/lua]

Caleb [import]uid: 147322 topic_id: 33493 reply_id: 141184[/import]

Hey Caleb, I’m having a few problems and hope you can help.

So I used your code up above and it all works nicely; however I’m trying to stop the Vent in scene:exitScene with TargetVentGroup:stop() and getting the following error:

CBEffects/Library.lua:299: attempt to concatenate local ‘t’ (a nil value)

I tried to use stopMaster(), which seemed to work perfectly however I noticed that when transitioning to the next scene p.kill is still being called. I put a print message in that function and noticed it still being called.

Am I stopping the vent correctly using this method or is there another way?

Many thanks, [import]uid: 33275 topic_id: 33493 reply_id: 141178[/import]

OK so I need to pass a table in if I use .stop() - however do you know why I’m having the issue with stopMaster()?

Also what parameter do I pass in to stop()?

Cheers, [import]uid: 33275 topic_id: 33493 reply_id: 141179[/import]

Scrub all that - I seem to have got it working - apologies :slight_smile: [import]uid: 33275 topic_id: 33493 reply_id: 141180[/import]

Hey!

Glad you got it working - just to clarify, I’ll post this.

When changing scenes, you should use the destroyMaster command. It completely nils out the VentGroup.
[lua]VentGroup:destroyMaster()
VentGroup=nil[/lua]
Stopping a vent simply stops the particles coming from it - things will continue to occur until the last round of particles emitted from it die.

The commands “stop”, “start”, “emit”, “destroy”, “get”, and “clean” commands take strings as arguments - the title of the vent(s) that you want to stop, start, emit, destroy, get, or clean. They can take as many arguments as there are vents in the VentGroup:
[lua]VentGroup:start(“MyVent1”, “MyVent2”, “MyVent3”)

VentGroup:start(“MyVent1”)[/lua]

Caleb [import]uid: 147322 topic_id: 33493 reply_id: 141184[/import]