SetAcceleration

This function sets an acceleration value for released particles.

Syntax

Returns

This function returns an integer ranging between 0 and 4 containing the specified view mode.

Remarks

float x- specified acceleration along the x-axis
float y- specified acceleration along the y-axis
float z- specified acceleration along the z-axis

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);

float acceleration = -0.5;
emitter->SetAcceleration(0, acceleration, 0);

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

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

if (window->KeyDown(Key::Up))
{
acceleration += .1;
emitter->SetAcceleration(0, acceleration, 0);
}
else if (window->KeyDown(Key::Down))
{
acceleration -= .1;
emitter->SetAcceleration(0, acceleration, 0);
}

context->SetBlendMode(Blend::Alpha);
context->DrawText("Current Y-axis Acceleration: " + String(emitter->GetAcceleration().y), 2, 2);
context->SetBlendMode(Blend::Solid);

context->Sync();
}
}