【问题标题】:Particle Effect [Does CCParticleSystemQuad change its position wrt to its parent]粒子效果 [CCParticleSystemQuad 是否将其位置更改为其父级]
【发布时间】:2015-09-07 08:40:44
【问题描述】:

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

  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 向左移动会发生什么,但是粒子效果似乎停留在它启动的位置,它是否也应该在其父级向左移动时向左移动?关于可能发生的事情有什么建议吗?当作为子项附加时,粒子效果的行为是否有所不同。我知道如果我附加了一个精灵,它会跟随父母。

【问题讨论】:

    标签: c++ iphone cocos2d-iphone cocos2d-x ccparticlesystem


    【解决方案1】:

    不,粒子效果应该跟随精灵。我什至将它们连接到节点(由 Young Peter 创建的 SpriterNode,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 版编写的。试试这个版本。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-08-01
      • 2023-03-15
      • 2013-05-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多