粒子效果[CCParticleSystemQuad是否将其位置更改为其父节点]

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

本文关键字:位置 父节点 CCParticleSystemQuad 是否 粒子      更新时间:2023-10-16

我有一个粒子系统,我以以下方式使用

  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);

现在发生的事情是这样的:BadSprites向左边移动,但是Particle效果似乎停留在它发射时的位置,它不也应该像它的父元素向左移动一样向左移动吗?有什么建议吗?当粒子效应被附加为儿童时,它们的行为会有所不同吗?我知道如果我附加了一个精灵,它会跟随父元素

不,粒子效果应该跟随精灵。我甚至将它们连接到节点(SpriterNode由Young Peter创建,http://weibo.com/young40),就像这样,一切都工作得很好:

_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]);

我看到你使用的是CCParticleSystemQuad,所以它是Cocos2d-x的旧版本。也许只是这样?我的例子是在3.6版本中编写的。