Created
February 20, 2011 02:22
-
-
Save daveWid/835614 to your computer and use it in GitHub Desktop.
Paint Streaks Class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Paint-like Streaks using the Flint particle generator. | |
* | |
* @author Dave Widmer | |
*/ | |
package net.davewidmer.flint | |
{ | |
import flash.filters.BlurFilter; | |
import flash.geom.Point; | |
import flash.geom.Rectangle; | |
import net.davewidmer.display.BaseSprite; | |
import org.flintparticles.common.actions.Age; | |
import org.flintparticles.common.counters.Steady; | |
import org.flintparticles.common.displayObjects.Dot; | |
import org.flintparticles.common.initializers.ColorInit; | |
import org.flintparticles.common.initializers.ImageClass; | |
import org.flintparticles.common.initializers.Lifetime; | |
import org.flintparticles.common.initializers.ScaleImageInit; | |
import org.flintparticles.twoD.actions.Move; | |
import org.flintparticles.twoD.emitters.Emitter2D; | |
import org.flintparticles.twoD.initializers.Position; | |
import org.flintparticles.twoD.initializers.Velocity; | |
import org.flintparticles.twoD.renderers.BitmapRenderer; | |
import org.flintparticles.twoD.zones.LineZone; | |
import org.flintparticles.twoD.zones.PointZone; | |
public class Streaks extends BaseSprite | |
{ | |
/** | |
* The particle emitter. | |
*/ | |
public var emitter:Emitter2D; | |
/** | |
* The particle renderer. | |
*/ | |
public var renderer:BitmapRenderer; | |
/** | |
* Creates a new Streaks instance. | |
*/ | |
public function Streaks() | |
{ | |
super(); | |
} | |
/** | |
* Starts the streaking. | |
*/ | |
public function start():void | |
{ | |
if(emitter == null) | |
{ | |
init(); | |
} | |
emitter.start(); | |
} | |
/** | |
* Stops the streaking. | |
*/ | |
public function stop():void | |
{ | |
emitter.stop(); | |
} | |
/** @inheritDoc */ | |
protected override function init():void | |
{ | |
// Create the emitter. | |
emitter = new Emitter2D(); | |
emitter.counter = new Steady(10); | |
// Initialize the emitter. | |
emitter.addInitializer(new ImageClass(Dot, 10)); | |
emitter.addInitializer(new ColorInit(0xFF35C219, 0xFF333333)); | |
emitter.addInitializer(new Position(new LineZone(new Point(-5, -5), new Point(625, -5)))); | |
emitter.addInitializer(new Velocity(new PointZone(new Point(0, 120)))); | |
emitter.addInitializer(new ScaleImageInit(0.5, 2)); | |
emitter.addInitializer(new Lifetime(2, 5)); | |
// Add actions to the emitter. | |
emitter.addAction(new Move()); | |
emitter.addAction(new Age()); | |
// Create the renderer. | |
renderer = new BitmapRenderer(new Rectangle(0, 0, 620, 500)); | |
renderer.addFilter(new BlurFilter(0, 0, 1)); | |
renderer.addEmitter(emitter); | |
addChild(renderer); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment