SetAnimationCycles
This function sets the number of times an animated particle's animation will play during one lifetime.
Syntax
- void SetAnimationCycles(int cycles)
Parameters
- cycles: The number of times a particle animation will loop.
Remarks
For smoother particle animations use the particle animation shader.
Example
#include "Leadwerks.h"
using namespace Leadwerks;
int main(int argc, const char *argv[])
{
float time = 0.5;
Leadwerks::Window* window = Leadwerks::Window::Create();
Context* context = Context::Create(window);
World* world = World::Create();
Camera* camera = Camera::Create();
camera->SetRotation(35, 0, 0);
camera->Move(0, 0, -3);
//Create an emitter
Emitter* emitter = Emitter::Create(1);
Material* material = Material::Load("Materials/Effects/explosion.mat");
if (material) emitter->SetMaterial(material);
emitter->SetVelocity(0, 0, 0, 0);
emitter->SetDuration(500);
emitter->SetEmissionVolume(0, 0, 0);
emitter->SetMaxScale(10.0);
emitter->SetAnimationRows(2);
emitter->SetAnimationColumns(5);
emitter->SetPosition(-1.5, 0, 0, true);
Emitter* emitter2 = Emitter::Create(1);
if (material)
{
emitter2->SetMaterial(material);
material->Release();
}
emitter2->SetVelocity(0, 0, 0, 0);
emitter2->SetDuration(500);
emitter2->SetEmissionVolume(0, 0, 0);
emitter2->SetMaxScale(10.0);
emitter2->SetAnimationRows(2);
emitter2->SetAnimationColumns(5);
emitter2->SetPosition(1.5, 0, 0, true);
emitter2->SetAnimationCycles(2);
while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;
Leadwerks::Leadwerks::Time::Update();
world->Update();
world->Render();
if (window->KeyDown(Key::Up) && time < 1.0)
{
time += .01;
}
else if (window->KeyDown(Key::Down) && time > 0.0)
{
time -= .01;
}
time = Math::Clamp(time, 0, 1);
context->SetBlendMode(Blend::Alpha);
context->DrawText(String(emitter->GetAnimationCycles()) + " Animation Cycles", 200, 500);
context->DrawText(String(emitter2->GetAnimationCycles()) + " Animation Cycles", 600, 500);
context->SetBlendMode(Blend::Solid);
context->Sync();
}
}