Particle snow transition

Forums Programming cocos2d support (graphics engine) Particle snow transition

This topic contains 12 replies, has 7 voices, and was last updated by  degborta 4 years, 5 months ago.

Viewing 13 posts - 1 through 13 (of 13 total)
Author Posts
Author Posts
October 16, 2009 at 6:34 am #217936

degborta
Participant
@degborta

I am playing around with the particle examples and using it on one of my layers in my testproject.

Everything is working great but I have a question.

In my project I have a Layer that fades into another Layer (the one that should have the snow on it). I am adding the snow particles on init in the second layer.

When the transition between the scenes is finished, the snow particles haven’t reached that far. They are on the top third part of the screen. It takes a second or two before they reach bottom.

This makes it pretty obvious that I just started the snow animation. I would like it to cover the whole screen with particles, so when the transition finishes it appears it has been snowing for a long time. But I am clueless to what I should do or look into.

Any tips or ideas are greatly appreciated.

October 16, 2009 at 11:59 am #263974

Codemattic
Moderator
@codemattic

In your subclass of your ParticleSystem you could add the ability to save and load its state, ie serialize it, to a file. Make a version where you let it run a bit, save its state, and in the game you load that state as your starting point for the system. Tricky but doable.

October 16, 2009 at 2:03 pm #263975

mobilebros
Moderator
@mobilebros

It makes sense to me that if you created any ParticleSystem and manually called update on it with a value of say 4 seconds that it would then appear to have “run” for 4 seconds, however I did a quick test and could not get it to work right (aka it had no effect). I did something similar to this:

ParticleSystem *ps = [ParticleSnow node];

[ps update:4];

[self addChild:ps];

Something like this should work, but it apparently needs something more that I’m missing… maybe I’ll get back to you.

October 16, 2009 at 2:35 pm #263976

Codemattic
Moderator
@codemattic

What if you called -step:4.0 instead? Or called -step:(4.0/kFPS) in a loop for (4.0*kFPS) times where kFPS=30.0 or whatever your frames per second is.

October 16, 2009 at 4:52 pm #263977

mobilebros
Moderator
@mobilebros

whoops, I meant step, not update. So yes I’ve tried looping as well, big and small values for both ways, for some reason it just does not take; I debugged a little and everything seems ok… but xcode is being flaky (debug values are sometimes not there or zero) since I updated the sdk.

October 16, 2009 at 9:03 pm #263978

Mark Sawicki
Participant
@effervescent

I haven’t tried it, but maybe you could start the particle system in ‘onEnter’ with a really fast speed, then in ‘onEnterTransitionDidFinish’ slow the particle system down to normal speed.

dunno ..

October 23, 2009 at 10:24 pm #263979

degborta
Participant
@degborta

Thanks for your input, I have tried both of your ideas now, but neither seems to solve my problem.

I set the speed to 100 and schedule a timeout for 3seconds on init, in the timeout I reset the speed to 20, as it is supposed to be.

But the problem here is that all particles that were created when I had the speed set to 100 keep falling at that speed, so they all quickly fall down below screen and disappear.

I absolutely have no idea as to what I can do to solve this. Any ideas are appreciated.

October 23, 2009 at 11:02 pm #263980

badawe
Participant
@badawe

Guys i have one question about particles, can i have more than one particle emitter positions?

Like i have 4 finger imputs and in all of then i want some particles, so i need 4 particles emitters? thats right?

October 24, 2009 at 1:23 am #263981

Codemattic
Moderator
@codemattic

@badawe yes!

October 24, 2009 at 2:20 am #263982

AkumaStreak
Participant
@akumastreak

I also vote that you should run update with a white lie delta time (one way or another) in order to effectively initialize them the way you want.

October 24, 2009 at 2:37 am #263983

degborta
Participant
@degborta

AkumaStreak: Can you explain further what you mean? I have tried playing around with the step- only, but it seems nothing happens at all. Couldn’t find the update method on the emitter.

Maybe I am doing something completely wrong.

October 24, 2009 at 6:09 am #263984

Lam
Moderator
@lam

@degborta

I think positional variance would help.

You should try Mark’s approach but instead of changing speed, change the emitters posVar.

Cache the old posVar during onEnter, set the new posVar to a large number, maybe the screen size.

Then onTransitionDidFinish reset the posVar.

It also might help to speed the emission rate. Since pos var let’s it emit particles in a larger region, younow need to emit faster.

So change position var and emission rate , then reset during a finished transition.

October 25, 2009 at 1:08 pm #263985

degborta
Participant
@degborta

Thanks for all your help guys! I finally solved thanks to @Lam‘s tip. Playing around with the posVar got it working!

Viewing 13 posts - 1 through 13 (of 13 total)

You must be logged in to reply to this topic.