Flocking
Flash required: You need version 9 or later of the free Flash player from Adobe to use this content. To download and install the free player from Adobe’s web site click here.
Source code
This uses three of Flint's actions that cause particles to interact with each other, causing the particles to approach one another but not get too close and to match velocity with each other. The result is flocking behaviour.
var emitter:Emitter2D = new Emitter2D(); emitter.counter = new Blast( 150 ); emitter.addInitializer( new ImageClass( Bird ) ); emitter.addInitializer( new Position( new RectangleZone( 10, 10, 680, 480 ) ) ); emitter.addInitializer( new Velocity( new DiscZone( new Point( 0, 0 ), 150, 100 ) ) ); emitter.addAction( new ApproachNeighbours( 150, 100 ) ); emitter.addAction( new MatchVelocity( 20, 200 ) ); emitter.addAction( new MinimumDistance( 10, 600 ) ); emitter.addAction( new SpeedLimit( 100, true ) ); emitter.addAction( new RotateToDirection() ); emitter.addAction( new BoundingBox( 0, 0, 700, 500 ) ); emitter.addAction( new SpeedLimit( 200 ) ); emitter.addAction( new Move() ); var renderer:DisplayObjectRenderer = new DisplayObjectRenderer(); renderer.addEmitter( emitter ); addChild( renderer ); emitter.start( );