Particle Candy director class

Hi
I have simple question how to write a code with particles and director class.
I have main.lua file and I making require particle libs in this file.
main.lua file sending my to mainmenu.lua (main menu of the game )file. I this file I’am starting and feeding particles.
EVERYTHING WORK GREAT:).
In mainmenu I have a buttons to switch to Options and Credits. And this is a problem.
When I switching to for example Credits (changeScene) what I have to do ? Freeze or CleanUP. ?
When I cleanup and go back to from credits to mainmenu I have an error because require is in main.lua not in mainmanu.lua. Freeze is not working too.

How I should use particle candy with director class in general when changing scene. Some Tips ?
I think this short explanation will be very helpful for many users… Thank you very much.:slight_smile: [import]uid: 13156 topic_id: 7004 reply_id: 307004[/import]

Hi Piotr,
we added a sample code to show how to use Particle Candy with Director Class. It will be included in the next update.

You can download it here for now:

Particle Candy & Director Class Sample [import]uid: 10504 topic_id: 7004 reply_id: 24615[/import]

Cool this what I need in one place Thanks [import]uid: 13156 topic_id: 7004 reply_id: 24626[/import]

Hi I need a little help once more…
I checked Director Class Sample everything works great, when I push the button and changing scene I’am making a CleanUp() but during the game when I go back to main menu ( I’am making a cleanUp() after play button ) everything extremely slows down. Should I make more cleanUp somewhere ? I think is something with memory buy I’am not sure… [import]uid: 13156 topic_id: 7004 reply_id: 24720[/import]

One more thing … its important. On simulator is perfect but slows down are on real device. [import]uid: 13156 topic_id: 7004 reply_id: 24721[/import]

In our project we are using the Director class with Particel Candy.
It seems to be realy difficult to use both together without getting erros during runtime.
In our game you can go from a level back to the main menu, if you are going back again to the
same level, you get a lot of errors. The cleanup seems to be the problem, specially when you
are using your FX Lbrary and the cleanup there, mixing with your own particel emitters and the
cleanup method particel.cleanup()
It is difficult to explain maybe I will post some examples if its necassary…

Greatings Michael [import]uid: 12632 topic_id: 7004 reply_id: 24748[/import]

What kind of errors do you get in detail and what version of the SDK (and what device) do you use? Could you send an example code to support -at- xpressive.com so we can have a look at it?

EDIT: Michael, we revised the clean up function and think this issue could be fixed now. Could you please send us your email address? We’d send you the fixed version so you can test if those errors still appear.

[import]uid: 10504 topic_id: 7004 reply_id: 24811[/import]

Can you tell me what was the problem ? I have no errors but I have the game is slowing down as I said when came back to main menu. (Emmiters are in main menu). [import]uid: 13156 topic_id: 7004 reply_id: 24981[/import]

Piotr, I just sent a revised version of the library to your email address. Please let us know if this solves your problem.
[import]uid: 10504 topic_id: 7004 reply_id: 25036[/import]

Wooow works great :):slight_smile:
I have to say very LOUD your support is awesome:)
Thank you [import]uid: 13156 topic_id: 7004 reply_id: 25074[/import]

So, after some strong tests I found that I was using an older Version of the Director Class!!!
I was studying the Particel Candy demo, and was wondering where they are calling the
cleanup. I found it in the Director Class…!!!
So be careful that you are using the latest version of Director Class.

There exist only a small cleanup problem when you are using an FXField. I get an error
during the cleanup when an FXField is integreted in the Director Class.
But anyway its an awesome support from Particel Candy…!!! [import]uid: 12632 topic_id: 7004 reply_id: 25107[/import]

When I try to use director class 1.2 whole game don’t even start. I have no time to check this , but I thought that is 100% compatible. I will check this later. [import]uid: 13156 topic_id: 7004 reply_id: 25110[/import]

@Michael: should be fixed now (please note the mail I send to you).

@Piotr: it’s hard to nail this down remotely. Could you send us a stripped-down sample code that demonstrates your problem?
[import]uid: 10504 topic_id: 7004 reply_id: 25223[/import]

I am trying to create an Emitter that stays with my main object as it moves through a series screens created using lime and tiled. I can create the emitter and set it to the x and y coordinates of the object, and then in my main() I update the position of the emitter to reflect movement in my object, but I can’t see my emitter nor does it seem to show.

Is there a simple way to attach an emitter to an object? [import]uid: 32632 topic_id: 7004 reply_id: 25284[/import]

my code

[code]
module(…, package.seeall)

function clean ( event )
Particles.CleanUp() ----- THIS I DON’T UNDERSTAND which event ?
DIRECTOR CLASS 1.1
I MAKING A CLEANUP WHEN USER TAP BUTTON
end

function new ()

local menuGroup = display.newGroup()
local ui = require(“ui”)
local physics = require(“physics”)
local tapSound = audio.loadSound( “blip.wav” )
local menuTheme = audio.loadStream( “menuTheme.wav” )
physics.start()
physics.setGravity(0,5)
local theTimer

Particles.CreateEmitter(“Beams” , 240, 120, 0, false, true)
local Properties = {}
Properties.imagePath = “beam.png”
Properties.imageWidth = 128 – PARTICLE IMAGE WIDTH (newImageRect)
Properties.imageHeight = 32 – PARTICLE IMAGE HEIGHT (newImageRect)
Properties.xReference = -64 – SET IMAGE REFERENCE TO LEFT IMAGE BORDER
Properties.velocityStart = 0 – PIXELS PER SECOND
Properties.alphaStart = 0 – PARTICLE START ALPHA
Properties.fadeInSpeed = 1.0 – PER SECOND
Properties.fadeOutSpeed = -1.0 – PER SECOND
Properties.fadeOutDelay = 1000 – WHEN TO START FADE-OUT
Properties.scaleStart = 0.75 – PARTICLE START SIZE
Properties.scaleVariation = 1.25 – RANDOM SCALE VARIATION
Properties.rotationVariation = 360 – RANDOM ROTATION
Properties.rotationChange = 10 – ROTATION CHANGE PER SECOND
Properties.weight = 0 – PARTICLE WEIGHT (>0 FALLS DOWN, <0 WILL RISE UPWARDS)
Properties.emissionShape = 0 – 0 = POINT, 1 = LINE, 2 = RING, 3 = DISC
Properties.killOutsideScreen = true – PARENT LAYER MUST NOT BE NESTED OR ROTATED!
Properties.lifeTime = 2000 – MAX. LIFETIME OF A PARTICLE
Particles.CreateParticleType (“BeamParticles”, Properties)
Particles.AttachParticleType(“Beams” , “BeamParticles” , 5, 99999, 0)
Particles.StartEmitter(“Beams”)
Particles.StartAutoUpdate()
menuGroup:insert(Particles.GetEmitter(“Beams”))

local drawMenu = function()

local playButton
local infoButton
local openButton
local playTaped = function(event)
if event.phase == “release” then
audio.play( tapSound )
Particles.CleanUp() -----------------HERE MAKING A CLEANUP
director:changeScene(“levels”, “fade”)
end
end
local infoTaped = function(event)
if event.phase == “release” then
audio.play( tapSound )

Particles.CleanUp() -------------- HERE MAKING A CLEANUP
director:changeScene(“credits”, “fade”)
end
end

playButton= ui.newButton{
defaultSrc = “playButton.png”,
defaultX = 140,
defaultY = 42,
overSrc = “playButton.png”,
overX = 150,
overY = 52,
onEvent = playTaped,
id = “PlayButton”,
text = “”,
font = “Helvetica”,
textColor = { 255, 255, 255, 255 },
size = 16,
emboss = false
}
playButton:setReferencePoint(display.BottomCenterReferencePoint)
playButton.x = 240
playButton.y = 200
menuGroup:insert(playButton)

physics.addBody(playButton, “static” , {density = 1.0, friction = 0.3, bounce = 0.2 })

infoButton= ui.newButton{
defaultSrc = “creditsButton.png”,
defaultX = 140,
defaultY = 42,
overSrc = “creditsButton.png”,
overX = 150,
overY = 52,
onEvent = infoTaped,
id = “PlayButton”,
text = “”,
font = “Helvetica”,
textColor = { 255, 255, 255, 255 },
size = 16,
emboss = false
}
infoButton:setReferencePoint(display.BottomCenterReferencePoint)
infoButton.x = 80
infoButton.y = 200
menuGroup:insert(infoButton)
infoButton:toFront()
physics.addBody(infoButton, “static” , {density = 1.0, friction = 0.3, bounce = 0.2 })

openButton= ui.newButton{
defaultSrc = “optionsButton.png”,
defaultX = 140,
defaultY = 42,
overSrc = “optionsButton.png”,
overX = 150,
overY = 52,
onEvent = infoTaped,
id = “PlayButton”,
text = “”,
font = “Helvetica”,
textColor = { 255, 255, 255, 255 },
size = 16,
emboss = false
}
openButton:setReferencePoint(display.BottomCenterReferencePoint)
openButton.x = 400
openButton.y = 200
menuGroup:insert(openButton)
openButton:toFront()
physics.addBody(openButton, “static” , {density = 1.0, friction = 0.3, bounce = 0.2 })

unloadMe = function()


end
drawMenu()
—audio.play( menuTheme, { channel=1, loops=-1, fadein=5000 } )

return menuGroup
end

[code]

but right now everything is ok when I put a new library from Mike. Why director class 1.2 doesn’t work I have no idea , but I thing is a small problem… or not :slight_smile: [import]uid: 13156 topic_id: 7004 reply_id: 25287[/import]

@tobephelps: You can attach an emitter to any group, same as with any other Corona display object. The problem with director is, however, that it DOES something with your groups where your scene stuff is located (they will be deleted on scene change). So if you want to create a persistent emitter that is NOT deleted on scene change, just don’t put it into the scene group or remove it from there before switching scenes.

Note, that you may have to bring the emitter to front again after switching to another scene, otherwise the new scene could be displayed on top, hiding the emitter behind.
@Piotr: Could you please send us a short sample code that demonstrates your problem? If we can get hands on working, executable code and are able to receive errors and debugging messages, we can track down the issue way faster than by digging through forum code.

[import]uid: 10504 topic_id: 7004 reply_id: 25308[/import]

Hi my Provisioning Profile is working again so I checked on real device the new library from x-pressive team…
Works great no slowdowns at all.
Ones more thank you. [import]uid: 13156 topic_id: 7004 reply_id: 25928[/import]