Playing with Flint
Damn I love messing with Flint – it is one seriously cool particle system 🙂 This is a little test I threw together tonight in about half an hour (includes creating the planet image!). Leave it for a few seconds to see the planet trail burn up, and then just click anywhere you want to re-position the gravity well!
[swfobj src=”http://sandbox.photonstorm.com/planet1.swf” width=”640″ height=”480″]
Code wise it’s extremely simple:
[as]
package
{
import flash.display.Bitmap;
import flash.display.Sprite;
import flash.geom.Point;
import flash.events.MouseEvent;
import flash.filters.BlurFilter;
import org.flintparticles.actions.*;
import org.flintparticles.activities.EmitterImage;
import org.flintparticles.activities.RotateEmitter;
import org.flintparticles.counters.*;
import org.flintparticles.debug.FrameTimer;
import org.flintparticles.emitters.*;
import org.flintparticles.initializers.*;
import org.flintparticles.zones.*;
public class tinderbox extends Sprite
{
private var emitter:PixelEmitter;
private var gravwell:GravityWell;
private var planet:Bitmap;
public function tinderbox():void
{
planet = new Bitmap(new planetPNG(90, 90));
planet.x = 354;
planet.y = 106;
init();
var t:FrameTimer = new FrameTimer();
addChild(t);
stage.addEventListener(MouseEvent.CLICK, randomGW, false, 0, true);
addChild(planet);
}
private function init():void
{
emitter = new PixelEmitter();
emitter.addFilter( new BlurFilter( 4, 4, 1 ) );
emitter.setCounter(new Pulse(1, 200));
emitter.addAction(new ColorChange(0xffffff00, 0xffdd0000));
emitter.addInitializer(new Position(new DiscZone(new Point(398, 150), 41)));
emitter.addInitializer(new Lifetime(4, 8));
emitter.addAction(new Age());
emitter.addActivity( new RotateEmitter(10));
emitter.addAction( new RandomDrift(40,40));
emitter.addAction(new Move());
emitter.addAction(new LinearDrag(0.5));
gravwell = new GravityWell(450, 47, 439);
emitter.addAction( gravwell );
addChild(emitter);
emitter.start();
}
private function randomGW(event:MouseEvent):void
{
var x:int = mouseX;
var y:int = mouseY;
trace(“new gw at ” + x + ” ” + y);
emitter.removeAction( gravwell );
gravwell = new GravityWell(470, x, y);
emitter.addAction( gravwell );
}
}
}
[/as]
Posted on April 10th 2008 at 10:46 pm by Rich.
View more posts in Experiments. Follow responses via the RSS 2.0 feed.
Make yourself heard
Hire Us
All about Photon Storm and our
HTML5 game development services
Recent Posts
OurGames
Filter our Content
- ActionScript3
- Art
- Cool Links
- Demoscene
- Flash Game Dev Tips
- Game Development
- Gaming
- Geek Shopping
- HTML5
- In the Media
- Phaser
- Phaser 3
- Projects
Brain Food