AddAlphaControlPoint

This function sets an Alpha control point that controls a particle's alpha transparency over the course of its life.

Syntax

Parameters

Remarks

Alpha control points work by interpolation from control point to control point over a particles lifetime. For example, if there is a control point at 0.0 with an alpha of 0.0 and a control point at 1.0 with an alpha of 1.0 the particle will gradual fade in over it's lifetime.

Example

#include "Leadwerks.h"

using namespace Leadwerks;

int main(int argc, const char *argv[])
{
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);
Light* light = DirectionalLight::Create();
light->SetRotation(35, 35, 0);

//Create an emitter
Emitter* emitter = Emitter::Create(100);

emitter->ClearAlphaControlPoints();//Remove default control points

emitter->AddAlphaControlPoint(0, 0); //at spawn the particle will have an alpha of 0 (fully transparent)
emitter->AddAlphaControlPoint(.5, 1); //halfway through the particle's lifetime alpha will be 1 (ie not transparent)
emitter->AddAlphaControlPoint(1, 0); //at death the particle will be fully transparent

while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;

Leadwerks::Leadwerks::Time::Update();
world->Update();
world->Render();

//if the space key is pressed all alpha control points are removed
if (window->KeyDown(Key::Space)) emitter->ClearAlphaControlPoints();

context->Sync();
}
}