I have a particle effect that updates it’s position every frame to match the position of another sprite. The sprite is on a layer that is scaled. When the layer is not scaled the particles follow the sprite properly, but when the layer is scaled the particles are out of position. Is this a bug or am I doing something wrong?
Example pseudo code:
CCLayer* layer
CCSprite* sprite
CCParticleSystem* effect
layer->addchild( sprite )
layer->addchild( effect )
layer->scale( 2.1333 )
// the sprite moves around the screen over time
sprite->setPosition( ccp( 123, 456 ) )
// the effect has an update scheduled so it can reposition each frame to match the sprites location
effect::update(ccTime dt)
{
this->setPosition( sprite->getPosition )
}
Doing this, the particle effect does not line up with the sprite in my case.
Actually, the particle emits from the correct location but the particles don’t behave correctly after they are created. I am using particle type kCCPositionTypeFree
It’s a bug with CCLayer. When you scale CCLayer, it make every child of this have wrong position
Just comment the line setAnchorPoint in the constructor of CCLayer. I don’t know why cocos2d need this line,but after do it,everything’s ok, no error