[转]龙卷风3

[url]http://wonderfl.net/c/nzcy[/url]

package
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Graphics;
import flash.display.Shape;
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.ColorTransform;
import sliz.miniui.Link;
/**
* ...
* @author sliz http://game-develop.net/blog
*/
public class Wind extends Sprite
{
private var p:Particle;
private var view:Bitmap;
private var pen:Shape = new Shape();
private var ct:ColorTransform = new ColorTransform(1, 1, 1, 1, 50, 50, 50);
private var step:int = 0;
public function Wind()
{
view = new Bitmap(new BitmapData(stage.stageWidth, stage.stageHeight, false, 0xffffff));
addChild(view);
var c:int = 200;
while (c-->0) {
var temp:Particle = new Particle();
temp.data = c;
if (p) {
temp.next = p;
}
p = temp;
}
addEventListener(Event.ENTER_FRAME, update);
var link:Link = new Link("Wind @author sliz");
addChild(link);
link.x = 10;
link.y = 10;
}

private function update(e:Event):void
{
var graphics:Graphics = pen.graphics;
graphics.clear();
graphics.lineStyle(0);
step+=5;
var x:Number = (Math.sin(step/30)+1)*(stage.stageWidth-100)/2+50;
var y:Number = stage.stageHeight - 20;
var temp:Particle = p;
while (temp) {
temp.x += (x - temp.x) * 0.9;
temp.y += (y - temp.y) * 0.9;
var d:Number = Number(temp.data);
graphics.drawEllipse(temp.x-d/2, temp.y, d,d/3);
x = temp.x + (Math.random() * d - d / 2) / 50;
y = temp.y - 3;
temp = temp.next;
}
view.bitmapData.colorTransform(view.bitmapData.rect, ct);
view.bitmapData.draw(pen);
}
}
}
class Particle
{
public var x:Number=0;
public var y:Number = 0;
public var data:Object;
public var next:Particle;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值