bug with particle effects on scaled layer?

bug with particle effects on scaled layer?
0.0 0


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

// CCLayer
    //setAnchorPoint(ccp(0.5f, 0.5f));
    m_bIsRelativeAnchorPoint = false;


No, I think it is not the cause here.
It is the bug in CCNode.
In CCNode::nodeToParentTransform(), it transform by anchor point by the code

// transform code
if( ! m_bIsRelativeAnchorPoint && ! CCPoint::CCPointEqualToPoint(m_tAnchorPointInPixels, CCPointZero) )
    m_tTransform = CCAffineTransformTranslate(m_tTransform, m_tAnchorPointInPixels.x, m_tAnchorPointInPixels.y);

And it recovers the effect by anchor point by the code

// recover code
if(! CCPoint::CCPointEqualToPoint(m_tAnchorPointInPixels, CCPointZero))
    m_tTransform = CCAffineTransformTranslate(m_tTransform, -m_tAnchorPointInPixels.x, -m_tAnchorPointInPixels.y);

The conditions are not the same.
So try to modify the recover code to

if(! m_bIsRelativeAnchorPoint && ! CCPoint::CCPointEqualToPoint(m_tAnchorPointInPixels, CCPointZero))
    m_tTransform = CCAffineTransformTranslate(m_tTransform, -m_tAnchorPointInPixels.x, -m_tAnchorPointInPixels.y);


I’m not sure,but why this error only happen when scale layer?
And more,is that a error with this setAnchorPoint line?
I wrote here but no one help me check it.

Although you set

m_bIsRelativeAnchorPoint = false;

When you scale a CCLayer, everything on this layer will have wrong position.