문제

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.

도움이 되었습니까?

해결책

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);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top