当前位置: 首页>>代码示例>>C++>>正文


C++ ParticleEffect::SetColorFrames方法代码示例

本文整理汇总了C++中ParticleEffect::SetColorFrames方法的典型用法代码示例。如果您正苦于以下问题:C++ ParticleEffect::SetColorFrames方法的具体用法?C++ ParticleEffect::SetColorFrames怎么用?C++ ParticleEffect::SetColorFrames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ParticleEffect的用法示例。


在下文中一共展示了ParticleEffect::SetColorFrames方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Set

void Explosion::Set(const Vector3 position, const Color color, const float size)
{
    Effect::Set(position);
    rootNode_->SetScale(size);
    initialMass_ = 3.0f * size;
    rigidBody_->SetMass(initialMass_);
    light_->SetColor(color);
    light_->SetBrightness(initialBrightness_);

    ParticleEffect* particleEffect = particleEmitter_->GetEffect();
    Vector<ColorFrame> colorFrames;
    colorFrames.Push(ColorFrame(Color(0.0f, 0.0f, 0.0f, 0.0f), 0.0f));
    Color mixColor = 0.5f * (color + particleEffect->GetColorFrame(1)->color_);
    colorFrames.Push(ColorFrame(mixColor, 0.1f));
    colorFrames.Push(ColorFrame(mixColor*0.1f, 0.35f));
    colorFrames.Push(ColorFrame(Color(0.0f, 0.0f, 0.0f, 0.0f), 0.0f));
    particleEffect->SetColorFrames(colorFrames);

    sampleSource_->SetGain(Min(0.5f*size, 1.0f));
    sampleSource_->Play(sample_);

    masterControl_->tileMaster_->AddToAffectors(WeakPtr<Node>(rootNode_), WeakPtr<RigidBody>(rigidBody_));

    SubscribeToEvent(E_POSTUPDATE, URHO3D_HANDLER(Explosion, UpdateExplosion));
}
开发者ID:1vanK,项目名称:heXon,代码行数:25,代码来源:explosion.cpp

示例2: Effect

Explosion::Explosion(Context *context, MasterControl *masterControl, Vector3 position, Color color, double size):
    Effect(context, masterControl, position),
    initialMass_{static_cast<float>(3.0f*size)},
    initialBrightness_{8.0f}
{
    rootNode_->SetName("Explosion");

    rootNode_->SetPosition(position);
    rootNode_->SetScale(size);

    rigidBody_ = rootNode_->CreateComponent<RigidBody>();
    rigidBody_->SetMass(initialMass_);
    rigidBody_->SetLinearFactor(Vector3::ONE - Vector3::UP);

    light_ = rootNode_->CreateComponent<Light>();
    light_->SetRange(13.0f);
    light_->SetColor(color);
    light_->SetBrightness(initialBrightness_);

    particleEmitter_ = rootNode_->CreateComponent<ParticleEmitter>();
    ParticleEffect* particleEffect = masterControl_->cache_->GetResource<ParticleEffect>("Resources/Particles/Explosion.xml");
    Vector<ColorFrame> colorFrames;
    colorFrames.Push(ColorFrame(Color(0.0f, 0.0f, 0.0f, 0.0f), 0.0f));
    Color mixColor = 0.5f * (color + particleEffect->GetColorFrame(1)->color_);
    colorFrames.Push(ColorFrame(mixColor, 0.1f));
    colorFrames.Push(ColorFrame(mixColor*0.1f, 0.35f));
    colorFrames.Push(ColorFrame(Color(0.0f, 0.0f, 0.0f, 0.0f), 0.0f));
    particleEffect->SetColorFrames(colorFrames);
    particleEmitter_->SetEffect(particleEffect);

    sample_ = masterControl_->cache_->GetResource<Sound>("Resources/Samples/Explode.ogg");
    sample_->SetLooped(false);
    sampleSource_ = rootNode_->CreateComponent<SoundSource>();
    sampleSource_->SetGain(Min(0.5f*size, 1.0f));
    sampleSource_->SetSoundType(SOUND_EFFECT);
    sampleSource_->Play(sample_);

    masterControl_->tileMaster_->AddToAffectors(WeakPtr<Node>(rootNode_), WeakPtr<RigidBody>(rigidBody_));

    SubscribeToEvent(E_POSTUPDATE, HANDLER(Explosion, UpdateExplosion));
}
开发者ID:sabotage3d,项目名称:heXon,代码行数:41,代码来源:explosion.cpp


注:本文中的ParticleEffect::SetColorFrames方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。