Question

I'm trying to make a rain effect. I used Particle Designer to create the effect. However in Cocos2d I need the rain to fall everywhere along the x axis, from the top of the screen, no matter how wide the screen is.

self.rainParticleSystem = [CCParticleSystemQuad particleWithFile:@"particle-rain.plist"];
    self.rainParticleSystem.positionType = kCCPositionTypeFree;
    self.rainParticleSystem.autoRemoveOnFinish = NO;
    self.rainParticleSystem.position = ccp(self.screenRight*0.5, self.screenTop);
    [self addChild:self.rainParticleSystem];

How can I "stretch" the emitter so that the rain falls from any x position on the screen? Right now I can only control it via Emitter Location X Variance in Particle Designer. I can't use hard coded plist values because I don't know what my screen size will be.

Was it helpful?

Solution

You can programmatically change emitter location variance through posVar property. Try something like this.-

self.rainParticleSystem.sourcePosition = ccp(SCREEN_WIDTH / 2, POSITION_Y);
self.rainParticleSystem.posVar = ccp(SCREEN_WIDTH / 2, 0);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top