最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
as3代码创建火效果代码
时间:2022-06-28 22:17:24 编辑:袖梨 来源:一聚教程网
as3代码创建火效果代码
下面为.swf文件调用方法
private function update(e:event):void {
target.filters = [new displacementmapfilter(bmd, new point(), bitmapdatachannel.red,bitmapdatachannel.red, 10, strengh, "clamp")];
offset=offset.add(v);
bmd.perlinnoise(size / 2, size, 3, randomseed, false, true, 1, true, [offset, offset]);
}
fireeffect.as
package effects
{
import flash.display.*
import flash.events.event;
import flash.filters.displacementmapfilter;
import flash.geom.*
/**
* ...
* @author sliz
*/
public class fireeffect extends sprite
{
private var bmd:bitmapdata;
private var target:sprite = createsharp(400, 30,0);
private var speed:number = math.random() * 4 + 4;
private var strengh:number = math.random() * 60 + 60;
private var size:number = math.random() * 17 + 20;
private var randomseed:number = math.floor(math.random() * 10);
private var offset:point = new point();
private var v:point;
private var w:number = 50;
public function fireeffect()
{
addchild(target);
addto(target);
target.x = 0;
target.y = 200;
}
private function createsharp(width:number,height:number,angle:number):sprite {
var s:sprite = new sprite();
s.graphics.beginfill(0, 0);
s.graphics.drawrect( -w, -w, width + 2 * w, w);
s.graphics.beginfill(0xffffff);
s.graphics.drawrect( -w, height, width + 2 * w, w);
var filltype:string = gradienttype.linear;
var colors:array = [0x900000, 0x900000,0xff9900,0xfffd8a,0xffffff];
var alphas:array = [0,1,1,1, 1];
var ratios:array = [0x00,0xff/16,0xff*2/6,0xff*2/3, 0xff];
var matr:matrix = new matrix();
matr.creategradientbox(width, height, math.pi / 2);
var spreadmethod:string = spreadmethod.pad;
s.graphics.begingradientfill(filltype, colors, alphas, ratios, matr, spreadmethod);
s.graphics.drawrect(0, 0, width, height);
return s;
}
public function addto(target:object):void {
bmd = new bitmapdata(target.width, target.height);
v = new point(math.random() * (speed / 4) - speed / 8,math.random() * (speed / 4) + speed / 4 * 3);
target.addeventlistener(event.enter_frame, update);
}
private function update(e:event):void {
target.filters = [new displacementmapfilter(bmd, new point(), bitmapdatachannel.red,bitmapdatachannel.red, 10, strengh, "clamp")];
offset=offset.add(v);
bmd.perlinnoise(size / 2, size, 3, randomseed, false, true, 1, true, [offset, offset]);
}
}
}main.as
package
{
import flash.display.sprite;
import effects.fireeffect;
import flash.events.mouseevent;
import flash.net.navigatetourl;
import flash.net.urlrequest;
import flash.text.textfield;
/**
* ...
* @author sliz
*/
public class main extends sprite
{
public function main():void {
addchild(new fireeffect());
var lable:textfield = new textfield();
lable.textcolor = 0xffffff;
lable.selectable = false;
lable.text = "sliz";
lable.addeventlistener(mouseevent.click, function():void { navigatetourl(new urlrequest("http://www.111com.net/")); } );
addchild(lable);
lable.x = 370;
lable.y = 380;
}
}
}
相关文章
- 王者荣耀侦探能力大测试攻略 王者荣耀侦探能力大测试怎么过 11-22
- 无期迷途主线前瞻兑换码是什么 11-22
- 原神欧洛伦怎么培养 11-22
- 炉石传说网易云音乐联动怎么玩 11-22
- 永劫无间手游确幸转盘怎么样 11-22
- 无期迷途主线前瞻兑换码是什么 无期迷途主线前瞻直播兑换码介绍 11-22