Skip to content
alyrow edited this page May 24, 2020 · 12 revisions

DOCUMENTATION

Particle system

ParticleSytem

This class create a particle system for manage your particles.

Using:

public ParticleSystem(int type, World world, Camera camera)

type: Particles type. See Particle types

world: If you want collisions between particles and others object put your box2D world. If not put null.

camera: For show particles and calculate if particles are outside the screen.

Methods:

public void setTexture(ParticleTexture texture)

Set particles texture through ParticleTexture object. Only works for TEXTURE and HALO type. See Particle types

public void setRules(ParticleRules rules)

Set particles rules. See ParticleRules

public void setPhysicManager(PhysicManager physicManager)

Set particles physics. See PhysicManager

public PhysicManager getPhysicManager()

Get particles physics. See PhysicManager

public void setParticlesPosition(float x, float y)

Set the first position of particles. If you modify this, it won't affect existing particles but futures.

public void dispose()

Free memory

public void render()

Render particles

public void enableBlending()
public void disableBlending()
public boolean isBlendingEnabled()
public int getBlendDstFunc()
public int getBlendSrcFunc()
public int getBlendSrcFuncAlpha()
public int getBlendDstFuncAlpha()
public void disableBlending(int srcFunc, int dstFunc
public void setBlendFunctionSeparate(int srcFuncColor, int dstFuncColor, int srcFuncAlpha, int dstFuncAlpha)

Blending functions for the sprite batch.

Particle Type

HALO

This particle type has a base texture. However you can set a custom texture. The difference with TEXTURE type is that the texture will be tinted with light color.

Use:

ParticleType.HALO

TEXTURE

For use custom texture.

Use:

ParticleType.TEXTURE

NOTHING

For only show the light.

Use:

ParticleType.NOTHING

Particle rules

ParticleRules

Using:

public ParticleRules()

Methods:

public void setLife(ParticleLife life)

Set life of particles with ParticleLife object.

public void setNumber(ParticleEmissionNumber number)

Set number of particles emitted with ParticleEmissionNumber object.

public void setDuration(ParticleEmissionDuration duration)

Set duration of emission with ParticleEmissionDuration object.

public void setLight(ParticleEmissionLight light)

Set light of particles with ParticleEmissionLight object.

Class texture

Particle texture

ParticleTexture

Usage:

public ParticleTexture(String path)

path: Path of your texture.

Random particle texture

RandomParticleTexture

Usage:

public RandomParticleTexture()

Methods:

public void addTexture(Texture texture)

Add a texture to the system

public void removeTexture(Texture texture)

Remove a texture from the system

Class rules

Particle emission duration

ParticleEmissionDuration

Use:

public ParticleEmissionDuration(float duration)

duration: Duration of the emission in seconds.

public ParticleEmissionDuration(boolean infinite)

infinite: Set infinite duration. Always put true!

Methods:

public void setDuration(float duration)

Set the duration of emission in seconds

public void setInfinite(boolean infinite)

Set if emission is infinite or not.

Particle emission light

ParticleEmissionLight

Use:

public ParticleEmissionLight(RayHandler rayHandler, int rays, Color color, float distance)

rayHandler: Put your RayHandler here.

rays: Number of rays that have lights. More is more realistic

color: Color of the lights

distance: Distance of the lights

public ParticleEmissionLight()

Use this if you doesn't want to use box2d light!

public ParticleEmissionLight(Color color)

Use this if you doesn't want to use box2d light but tint your particles in HALO mode!

Particle emission light random

ParticleEmissionLightRandom

Use:

public ParticleEmissionLightRandom(RayHandler rayHandler, int rays, Color color, float distance_min, float distance_max)

rayHandler: Put your RayHandler here.

rays: Number of rays that have lights. More is more realistic

color: Color of the lights

distance_min: Minimum distance of the lights

distance_max: Maximum distance of the lights

Particle emission number

ParticleEmissionNumber

Use:

public ParticleEmissionNumber(int mode, int number)

mode: Mode of the emission. See Mode below.

number: Number of particles

Method:

public void setDelay(int seconds)

Set a delay in seconds between emission and only with PER_SECONDS mode!

Mode:

INNER_SCREEN

Number of particles visible in the screen.

Usage:
ParticleEmissionNumber.INNER_SCREEN
PER_SECONDS

Number of particles emitted per second

Usage:
ParticleEmissionNumber.PER_SECONDS

Particle emission number random

ParticleEmissionNumberRandom

Usage:

public ParticleEmissionNumberRandom(int mode, int min, int max)

mode: See upper

min: Minimum number of particles

max: Maximum number of particles

Particle life

ParticleLife

Usage:

public ParticleLife(float life)

life: Life of particles in seconds

public ParticleLife(float life, boolean outer)

life: Life of particles in seconds

outer: If true, particles survive life seconds outside the screen then die.

Particle life random

ParticleLifeRandom

Usage:

public ParticleLife(float life_min, float life_max)

life_min: Minimum life of particles in seconds

life_max: Minimum life of particles in seconds

public ParticleLifeRandom(float life_min, float life_max, boolean outer)

life_min: Minimum life of particles in seconds

life_max: Minimum life of particles in seconds

outer: If true, particles survive life seconds outside the screen then die.

Class physics

Physic manager

PhysicManager

Use:

public PhysicManager()

Methods:

public void addForce(PhysicForce force)

Add force to the physic manager

public void removeForce(PhysicForce force)

Remove force to the physic manager

PhysicForce

This is the base class for make forces. See improve this library for more details.

Brownian force

BrownianForce

Use:

public BrownianForce(float strength, long seed, double frequency)

strength: Strength of the force

seed: Seed of the force

frequency: Lower means more quiet

public BrownianForce(float strength_x, float strength_y, long seed, double frequency)

strength_x: Strength of the force for x axis

strength_y: Strength of the force for y axis

seed: Seed of the force

frequency: Lower means more quiet

Linear force

LinearForce

Use:

public LinearForce(float vx, float vy)

vx: x axis intensity

vy: y axis intensity

Random linear force

RandomLinearForce

Use:

public RandomLinearForce(float vx_min, float vx_max, float vy_min, float vy_max)

vx_min: Min value for x axis

vx_max: Max value for x axis

vy_min: Min value for y axis

vy_max: Max value for y axis

Radial force

RadialForce

Use:

public RadialForce(float strength)

strength: Strength of the force

Random radial force

RandomRadialForce

Use:

public RandomRadialForce(float strength_min, float strength_max)

strength_min: Minimum strength of the force

strength_max: Maximum strength of the force