GetMaxScale

This function returns the max scaling factor for particles. The original particle size is multiplied by the scaling factor to get the final size.

Syntax

Returns

This function returns a float containing the maximum scaling factor for a particle.

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->Move(0, 0, -3);

float maxscale = 1;

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

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

emitter->AddScaleControlPoint(0, 0); //at spawn the particle will have an alpha of 0 (fully transparent)
emitter->AddScaleControlPoint(.5, 1); //halfway through the particle's lifetime alpha will be 1 (ie not transparent)
emitter->AddScaleControlPoint(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();

//use up and down arrow key to adjust maxscale
if (window->KeyDown(Key::Up))
{
++maxscale;
emitter->SetMaxScale(maxscale);
}
else if (window->KeyDown(Key::Down) && maxscale > 0)
{
--maxscale;
emitter->SetMaxScale(maxscale);
}

context->SetBlendMode(Blend::Alpha);
context->DrawText("Max Scale: " + emitter->GetMaxScale().ToString(), 2, 2);
context->SetBlendMode(Blend::Solid);

context->Sync();
}
}