Particle Candy - fireworks Question

Ok this is going to be simple for the particle candy people, but it’s been driving me nuts!!!

so here goes my question.

Using your fireworks example I copied the code line per line…

How do i get the fireworks to burst at a hire location instead of in the middle of the screen?
That’s it plain and simple…

Help would be GREAT! :slight_smile:

thanks

Larry

[import]uid: 11860 topic_id: 35674 reply_id: 335674[/import]

I just released a game which used the Fireworks sample as a starting point:

https://itunes.apple.com/us/app/fireworks-frenzy/id595640685?mt=8

I’ll dig out some code when I get home, but the basis of it was to split the code that launches the rocket and the code that does the explosion.

I could then call the explosion at any time (i.e. when the player swipes across the rocket or the rocket reaches a certain point on screen). [import]uid: 93133 topic_id: 35674 reply_id: 141866[/import]

That would be wonderful :slight_smile: thanks so much :slight_smile: [import]uid: 11860 topic_id: 35674 reply_id: 141904[/import]

Hey, @doubleslashdesign, in case you’re still looking for a solution, what you need to do is to set/change the x/y coordinate of the emitter, either when you create the emitter or whenever you want to reposition it.

If you want to position an emitter at the time you create it, then setting the value of x and y position would do. The sample is positioned in the center:

-- this is copied from the sample fireworks  
-- CREATE EMITTERS (NAME, SCREENW, SCREENH, ROTATION, ISVISIBLE, LOOP)  
Particles.CreateEmitter("Explosion1", screenW\*0.5, screenH\*0.5, 180, false, false)  

Change it from the center of the screen to x=100 and y=100 position at the time the emitter is created:

-- SCREENW is the x and SCREENH is the y position  
Particles.CreateEmitter("Explosion1", 100, 100, 180, false, false)  

If you want to change the position of the emitter at runtime instead, I think we need to get the emitter first, then set its position. Edit: I see on Fireworks sample how it resets the position of the emitter, which is different from what I thought how it works. So I’ve edited the code.

-- assuming you created the emitter called "Explosion1"  
Particles.GetEmitter("Explosion1").x = 100  
Particles.GetEmitter("Explosion1").y = 100  

I just wrote this up, and I haven’t verified the code, so it may not work. But maybe it can help get your code working…?

Naomi [import]uid: 67217 topic_id: 35674 reply_id: 142017[/import]

I dont really want to change the position of the emitter… That is changing where the emitter ( starts from )
(Number) Emitter’s initial x- and y-coordinate.

I want to change the distance on the screen that it travels… currently it is exploding in the middle area of the screen, I would like to change some to explode towards the top and some towards the bottom, even if they are hard coded they will appear random :wink:

Larry [import]uid: 11860 topic_id: 35674 reply_id: 142019[/import]

Hey, Larry, I’m not sure if we are looking at the same sample code? When I run the project folder that says “Sample_Visuals_Fireworks”, the rocket shoots off in various directions and the fireworks explosions happen in various locations (mostly upper side of the horizontal screen).

Anyhow, if you want the explosions to happen on a specific location, you’d have to give the x & y coordinates to the Explosion emitter. If you want the Launcher emitter to end at a specific location (and have the explosion to take place where Launcher emitter ends), then I think you’d need to play with the Rocket particle type that is attached to the Launcher emitter (like velocityStart, velocityVariation, directionVariation, etc.) and try to get the Launcher emitter to end where you want it to end, maybe?

From what I understand, Explosion happens on a fixed location (i.e., it happens where Launcher ends), while the Launcher emitter shoots up from bottom center of the screen, and goes where it goes based on the Rocket particle type it’s been given. Hmmm… I wonder if I misunderstood this effect…

Naomi [import]uid: 67217 topic_id: 35674 reply_id: 142023[/import]

One more thought… If you are plugging in the sample code directly to your app, and if your app happens to be on portrait, and if the launcher doesn’t simply travel high enough before explosion happens, I think there are a couple of things I might try as a super quick fix:

  1. Extend the lifeTime of the Rocket particle type (which I think would allow the Launcher to travel further on its course.)

  2. Or… add some pixel to event.y where Launcher ends. This way the Explosions will take place some pixels higher than where Launcher ends up with. Meaning, inside the [text]Particles.SetEmitterListener(“Launcher”, function(event)[/text], add some pixels to event.y where Explosion takes place. Adding 50 or 100 pixels to the event.y might just do the trick.

  3. Ah, another one. Have the launcher start much higher than the bottom of the screen. Maybe have it start from the middle of the screen? It would definitely end much higher than the middle of the screen and the explosion would take place even higher.

Anyhow, it’s just some random thoughts… Anyhow, good luck with the fireworks.

Naomi

Edit: Wait, you want the explosion to happen at the bottom too? And you want the Launcher too? Then you’d really need to have the launcher start in the middle of the screen and travel not just upward with some variation, but travel in every direction… And perhaps you need to give variation to the lifeTime too so that Launcher may end soon after it starts (resulting in the explosion happening in the middle of the screen too.) Hmmm, it sounds like the Launcher’s particle type properties may need some big changes… [import]uid: 67217 topic_id: 35674 reply_id: 142028[/import]

I just released a game which used the Fireworks sample as a starting point:

https://itunes.apple.com/us/app/fireworks-frenzy/id595640685?mt=8

I’ll dig out some code when I get home, but the basis of it was to split the code that launches the rocket and the code that does the explosion.

I could then call the explosion at any time (i.e. when the player swipes across the rocket or the rocket reaches a certain point on screen). [import]uid: 93133 topic_id: 35674 reply_id: 141866[/import]

That would be wonderful :slight_smile: thanks so much :slight_smile: [import]uid: 11860 topic_id: 35674 reply_id: 141904[/import]

Hey, @doubleslashdesign, in case you’re still looking for a solution, what you need to do is to set/change the x/y coordinate of the emitter, either when you create the emitter or whenever you want to reposition it.

If you want to position an emitter at the time you create it, then setting the value of x and y position would do. The sample is positioned in the center:

-- this is copied from the sample fireworks  
-- CREATE EMITTERS (NAME, SCREENW, SCREENH, ROTATION, ISVISIBLE, LOOP)  
Particles.CreateEmitter("Explosion1", screenW\*0.5, screenH\*0.5, 180, false, false)  

Change it from the center of the screen to x=100 and y=100 position at the time the emitter is created:

-- SCREENW is the x and SCREENH is the y position  
Particles.CreateEmitter("Explosion1", 100, 100, 180, false, false)  

If you want to change the position of the emitter at runtime instead, I think we need to get the emitter first, then set its position. Edit: I see on Fireworks sample how it resets the position of the emitter, which is different from what I thought how it works. So I’ve edited the code.

-- assuming you created the emitter called "Explosion1"  
Particles.GetEmitter("Explosion1").x = 100  
Particles.GetEmitter("Explosion1").y = 100  

I just wrote this up, and I haven’t verified the code, so it may not work. But maybe it can help get your code working…?

Naomi [import]uid: 67217 topic_id: 35674 reply_id: 142017[/import]

I dont really want to change the position of the emitter… That is changing where the emitter ( starts from )
(Number) Emitter’s initial x- and y-coordinate.

I want to change the distance on the screen that it travels… currently it is exploding in the middle area of the screen, I would like to change some to explode towards the top and some towards the bottom, even if they are hard coded they will appear random :wink:

Larry [import]uid: 11860 topic_id: 35674 reply_id: 142019[/import]

Hey, Larry, I’m not sure if we are looking at the same sample code? When I run the project folder that says “Sample_Visuals_Fireworks”, the rocket shoots off in various directions and the fireworks explosions happen in various locations (mostly upper side of the horizontal screen).

Anyhow, if you want the explosions to happen on a specific location, you’d have to give the x & y coordinates to the Explosion emitter. If you want the Launcher emitter to end at a specific location (and have the explosion to take place where Launcher emitter ends), then I think you’d need to play with the Rocket particle type that is attached to the Launcher emitter (like velocityStart, velocityVariation, directionVariation, etc.) and try to get the Launcher emitter to end where you want it to end, maybe?

From what I understand, Explosion happens on a fixed location (i.e., it happens where Launcher ends), while the Launcher emitter shoots up from bottom center of the screen, and goes where it goes based on the Rocket particle type it’s been given. Hmmm… I wonder if I misunderstood this effect…

Naomi [import]uid: 67217 topic_id: 35674 reply_id: 142023[/import]

One more thought… If you are plugging in the sample code directly to your app, and if your app happens to be on portrait, and if the launcher doesn’t simply travel high enough before explosion happens, I think there are a couple of things I might try as a super quick fix:

  1. Extend the lifeTime of the Rocket particle type (which I think would allow the Launcher to travel further on its course.)

  2. Or… add some pixel to event.y where Launcher ends. This way the Explosions will take place some pixels higher than where Launcher ends up with. Meaning, inside the [text]Particles.SetEmitterListener(“Launcher”, function(event)[/text], add some pixels to event.y where Explosion takes place. Adding 50 or 100 pixels to the event.y might just do the trick.

  3. Ah, another one. Have the launcher start much higher than the bottom of the screen. Maybe have it start from the middle of the screen? It would definitely end much higher than the middle of the screen and the explosion would take place even higher.

Anyhow, it’s just some random thoughts… Anyhow, good luck with the fireworks.

Naomi

Edit: Wait, you want the explosion to happen at the bottom too? And you want the Launcher too? Then you’d really need to have the launcher start in the middle of the screen and travel not just upward with some variation, but travel in every direction… And perhaps you need to give variation to the lifeTime too so that Launcher may end soon after it starts (resulting in the explosion happening in the middle of the screen too.) Hmmm, it sounds like the Launcher’s particle type properties may need some big changes… [import]uid: 67217 topic_id: 35674 reply_id: 142028[/import]