火の玉
77行目のalphaの減り具合を調整してたら火の玉っぽくなりました。
mouseの動きについてきます。
mouseDown = false:赤い炎
mouseDown = true: 青い炎
/**
* Copyright geko ( http://wonderfl.net/user/geko )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/fPDP
*/
// forked from KoheiTAKAMIYA's Flurryを作...れなかった
package {
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.ui.Mouse;
[SWF(frameRate="60")]
public class FlashTest extends Sprite {
private var bmp:Bitmap = new Bitmap();
private var flurry:Flurry;
private var i:Number = 0;
private var mouseDown:Boolean = false;
public function FlashTest() {
Mouse.hide();
bmp.bitmapData = new BitmapData(stage.stageWidth, stage.stageHeight, false, 0x000000);
addChild(bmp);
addEventListener(Event.ENTER_FRAME, loop);
stage.addEventListener(MouseEvent.MOUSE_DOWN, function():void{mouseDown=true;});
stage.addEventListener(MouseEvent.MOUSE_UP, function():void{mouseDown=false;});
}
public function loop(event:Event):void{
i+=0.02;
flurry = new Flurry(Math.cos(Math.PI/2*i)*0.5, -1, Math.random()*0.05, -0.03, mouseDown ? 0x3366CC : 0xCC6633);
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
&& target.alpha > 0) 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, color:uint = 0xCC6633):void{
blendMode = BlendMode.ADD;
filters = [filter];
spout.x = spoutX;
spout.y = spoutY;
wind.x = windX;
wind.y = windY;
graphics.beginFill(color);
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.03;
}
}