Particle Effect [Does CCParticleSystemQuad change its position wrt to its parent]

86 Views Asked by At

I have a particle system that I use in the following manner

  DustParticle = CCParticleSystemQuad::create("dust_texture.plist");
    Vec2 pos =   Vec2(
                      BadSprite->getPositionX() 
                      BadSprite->getPositionY() 
                     );
    Vec2 World = BadSprite->getParent()->convertToWorldSpace(pos);
    Vec2 Node =  BadSprite->convertToNodeSpace(World);
    DustParticle->setPosition(Node);

    BadSprite->addChild(DustParticle);

Now here is what happens BadSprites is moving towards the left however the Particle effect seems to be stuck at the position it was launched at isnt it also suppose to move left as its parent is moving left? Any suggestions on what might be going on ? Do particle effects behave different when attached as children. I know if I attached a sprite it will follow the parent.

1

There are 1 best solutions below

0
alc77 On

No, particle effects should follow the sprite. I connected them even to the Node (SpriterNode created by Young Peter, http://weibo.com/young40), like this, and everything worked fine:

_characterNode = SpriterNode::create(nameScml,namePng);
_characterNode->setContentSize(sprObject->getContentSize());
this->addChild(_characterNode);

power[0] = ParticleSystemQuad::create("particle_light.plist"); // it was an array of effects on the one object
power[0]->setPosition(0, 0.5 * _characterNode->getContentSize().height);
_characterNode->addChild(power[0]);

I see you're using CCParticleSystemQuad, thus it's some older version of Cocos2d-x. Maybe it's just this? My example is written in version 3.6. Try this version.