shouldDrawParticles : bool
shouldDrawEmitters : bool
isPlaying : bool
init(HTMLCanvasElement canvas) : void
play() : void
pause() : void
setFPS(int fps) : void
addEmitter(BBParticleEmitter emitter) : void
addHyperVoxels(BBHyperVoxelSystem hv) : void
drawScene() : void
shouldDrawParticles : bool
Holds whether the world should draw the particles as dots, even without a hyper voxel system.
shouldDrawEmitters : bool
Holds whether the world should draw the emitters as a box.
isPlaying : bool
True if the world is playing. False otherwise. Do not edit this property directly. Use the play() and pause() functions instead.
init(HTMLCanvasElement canvas) : void
Initiates the world with the given canvas element that it will be using to draw on and starts the animation.
play() : void
Starts the animation.
pause() : void
Pauses the animation.
setFPS(int fps) : void
Sets the frame rate of the world in frames per second. Do not change the frame rate directly, as that will not update emitters as well. Only use this function.
addEmitter(BBParticleEmitter emitter) : void
Adds a particle emitter to the world.
addHyperVoxels(BBHyperVoxelSystem hv) : void
Adds a hyper voxel system to the world.
drawScene() : void
Draws the scene that the particle emitters are in. This function is called before all other drawing. By default, it simply clears the canvas. However, you can change it to whatever you like so that the particles can exist in a scene that you create. For example, the following would render particles in a scene with a two by two checkerboard background:
var ctx = document.getElementById('canvas').getContext('2d');
var world = new BBParticleWorld();
world.drawScene = function()
{
ctx.clearRect(0, 0, 20, 20);
ctx.fillStyle = "red";
ctx.fillRect(0, 0, 10, 10);
ctx.fillRect(10, 10, 10, 10);
}