Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Cleaning up some comments

  • Loading branch information...
commit 7e710ff8cc36450bc9aaa50e2a5d15bd41f40c56 1 parent 4932674
@alecmce authored
View
8 src/Example.as
@@ -27,15 +27,15 @@ package
private function init():void
{
- ticker = new Ticker();
- properties = generateProperties();
- system = new ParticleSystem(properties);
+ system = new ParticleSystem(generateProperties());
addChild(system);
data = new ParticleData(system);
addChild(data);
- ticker.add(system.iterate);
+ ticker = new Ticker();
+ ticker.add(system.iterate);
+ ticker.add(data.iterate);
}
private function generateProperties():ParticleProperties
View
27 src/alecmce/particles/Particle.as
@@ -2,6 +2,14 @@ package alecmce.particles
{
import flash.display.BitmapData;
+ /**
+ * The Particle class holds a position in the Euclidean plane and expects
+ * to draw to the target BitmapData each time it is iterated.
+ *
+ * (c) 2010 alecmce.com
+ *
+ * @author Alec McEachran
+ */
public class Particle
{
@@ -12,16 +20,25 @@ package alecmce.particles
public var height:uint;
public var color:uint;
-
+
+ /**
+ * init is called each time the particle object is to become active; the
+ * properties object is passed through generically because of a language
+ * limitation
+ *
+ * FIXME when Adobe finally implement generics, do this properly!
+ */
public function init(properties:ParticleProperties):void
{
- // do nothing
+ // to be overridden
}
-
+
+ /**
+ * iterate should draw to data as appropriate, and then return true iff
+ * the particle should be recycled
+ */
public function iterate(data:BitmapData):Boolean
{
- data; // avoid unused-variable warning
-
return false;
}
View
33 src/alecmce/particles/ParticleProperties.as
@@ -3,13 +3,27 @@ package alecmce.particles
import flash.display.BitmapData;
import flash.geom.Point;
+ /**
+ * The ParticleProperties class holds a collection of properties that allow a
+ * Particle object to be configured at runtime, and encapsulates three methods
+ * that determine how a ParticleSystem will be filtered before and after the
+ * particles are drawn, and what persistent filters are applied to it at
+ * startup
+ *
+ * (c) 2010 alecmce.com
+ *
+ * @author Alec McEachran
+ */
public class ParticleProperties
{
public static const ORIGIN:Point = new Point(0, 0);
private var _max:uint;
+ /** the working maximum number of particles that can be in the system. Must be <= _max */
public var throttle:uint;
+
+ /** how many new particles are created per frame, when available */
public var releasedPerFrame:Number;
public var width:uint;
@@ -28,25 +42,38 @@ package alecmce.particles
releasedPerFrame = 1;
}
-
+
+ /**
+ * the maximum number of particles that can be created by the system
+ */
public function get max():uint
{
return _max;
}
+ /**
+ * referenced once at the start of a ParticleSystem's initialization routine, configures
+ * the 'permanent' filters that are applied to the system
+ */
public function generateEmitterFilters():Array
{
return [];
}
+ /**
+ * called before the particles of a particle system are drawn into the BitmapData
+ */
public function pre(data:BitmapData):void
{
-
+ // to be overridden
}
+ /**
+ * called after the particles of a particle system are drawn into the BitmapData
+ */
public function post(data:BitmapData):void
{
-
+ // to be overridden
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.