Flurryを作...れなかった
【Flurryを作りたい】
ver.1 2010.09.23
sin,cosでウニウニさせてみる.
Math.random()を使うと煙に近くなった.
EnterFrameでどんどんaddChild()しているので処理は激重...
/**
* Copyright geko ( http://wonderfl.net/user/geko )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/pRCG
*/
package {
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.events.Event;
[SWF(frameRate="60")]
public class FlashTest extends Sprite {
private var bmp:Bitmap = new Bitmap();
private var flurry:Flurry;
private var i:Number = 0;
public function FlashTest() {
bmp.bitmapData = new BitmapData(stage.stageWidth, stage.stageHeight, false, 0x000000);
addChild(bmp);
addEventListener(Event.ENTER_FRAME, loop);
}
public function loop(event:Event):void{
i+=0.02;
flurry = new Flurry(3, Math.sin(Math.PI/2*i), 0.03, 0);
// ↓こっちでnewしたら煙っぽい
// flurry = new Flurry(Math.cos(Math.PI/2*i)*0.5, -1, Math.random(), -0.5);
addChild(flurry);
flurry.x = mouseX;
flurry.y = mouseY;
flurry.addEventListener(Event.ENTER_FRAME, function update(event:Event):void{
var target:Flurry = event.target as Flurry;
target.update();
if(Math.min(Math.max(target.x, -3), stage.stageWidth+3) == target.x &&
Math.min(Math.max(target.y, -3), stage.stageHeight+3) == target.y) return;
target.removeEventListener(Event.ENTER_FRAME, update);
removeChild(target);
target = null;
});
}
}
}
import flash.display.Shape;
import flash.display.BlendMode;
import flash.events.Event;
import flash.filters.BlurFilter;
class Flurry extends Shape{
private var filter:BlurFilter = new BlurFilter(10, 10, 3);
private var spout:Object = new Object();
private var wind:Object = new Object();
public function Flurry(spoutX:Number = 0, spoutY:Number = 0, windX:Number = 0, windY:Number = 0):void{
blendMode = BlendMode.ADD;
filters = [filter];
spout.x = spoutX;
spout.y = spoutY;
wind.x = windX;
wind.y = windY;
graphics.beginFill(0x33CCCC);
graphics.drawCircle(0, 0, 6);
graphics.endFill();
}
public function update():void{
spout.x += wind.x;
spout.y += wind.y;
x += spout.x;
y += spout.y;
alpha -= 0.005;
}
}