particles in particle systems behaves weird
-
20-06-2021 - |
Question
i have a node (named 'terrain') that i offset so that my main game object (my character) stays in the center of the screen. i do this like this:
[_terrain setOffsetX:offsetX andOffsetY:offsetY*4/3];
the thing is that on my terrain, i have a particle system. When moving my character (and thus offsetting the terrain) the particles emitted are not mentaining their up-word trajectory. It looks like the particles emitted are dephased. Here is my particle system code that i include in my terrain class (i.e. self refers to the terrain itself) :
emitterSnow = [CCParticleSnow node];
emitterSnow.position = startPoint;
[emitterSnow setAnchorPoint:CGPointZero];
[self addChild:emitterSnow z:0 tag:windIndicatorTag];
CGPoint p = emitterSnow.position;
emitterSnow.position = ccp( p.x + width/2 , p.y);
emitterSnow.life = 1;
emitterSnow.lifeVar = .3f;
[emitterSnow setIsRelativeAnchorPoint:YES];
emitterSnow.posVar = CGPointMake(width/2,0);
// gravity
emitterSnow.gravity = ccp(0,1000);
// speed of particles
emitterSnow.speed = 140;
emitterSnow.speedVar = 20;
ccColor4F startColor = emitterSnow.startColor;
startColor.r = 0.9f;
startColor.g = 0.9f;
startColor.b = 0.9f;
emitterSnow.startColor = startColor;
ccColor4F startColorVar = emitterSnow.startColorVar;
startColorVar.b = 0.1f;
emitterSnow.startColorVar = startColorVar;
emitterSnow.emissionRate = 30;
emitterSnow.texture = [[CCTextureCache sharedTextureCache] addImage: @"bubble2.png"];
How can i have my particles move up from my particle system source?
Solution
Try setting the positionType
(a tCCPositionType
). Use kCCPositionTypeFree
(default one) for moving particles freely. Or use kCCPositionTypeGrouped
to move them in a group.