粒子有x,y,vx,vy属性,vx,vy为速度。
色彩变换用colortransform的参数变换实现
飘影用位图的appleTransform
代码如下 | 复制代码 |
package { import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.Shape; import flash.display.Sprite; import flash.events.Event; import flash.events.MouseEvent; import flash.geom.ColorTransform; /** * ... * @author lizhi http://www.111com.net/ */ [SWF(width=465,height=465,backgroundColor=0xffffff,frameRate=60)] public class Main extends Sprite { private var w:int; private var h:int; private var ps:Array; private var pen:Shape = new Shape; private var bmd:BitmapData; private var ct:ColorTransform = new ColorTransform(0.999, 0.95, 0.99); private var max:Number = ct.redMultiplier; private var min:Number = ct.blueMultiplier; private var vr:Number = 0.0001; private var vg:Number = vr; private var vb:Number = vr; public function Main():void { w = stage.stageWidth; h = stage.stageHeight; bmd = new BitmapData(w, h, false, 0); addChild(new Bitmap(bmd)); var c:int = 10; ps = []; while (c-->0) { ps.push(new Particle(w * Math.random(), h * Math.random(),(Math.random()-0.5)*2,(Math.random()-0.5)*2)); } addEventListener(Event.ENTER_FRAME, init); } private function init(e:Event = null):void { for each(var p:Particle in ps) { p.x += p.vx; p.y += p.vy; if (p.x<0) { p.x = 0; p.vx = Math.abs(p.vx); } if (p.y<0) { p.y = 0; p.vy = Math.abs(p.vy); } if (p.x>w) { p.x = w; p.vx = -Math.abs(p.vx); } if (p.y>h) { p.y = h; p.vy = -Math.abs(p.vy); } } pen.graphics.clear(); pen.graphics.lineStyle(0,0xffffff); pen.graphics.moveTo(ps[0].x/2+ps[1].x/2,ps[0].y/2+ps[1].y/2); for (var i:int = 1; i < ps.length; i++ ) { p = ps[i + 1]; if (p == null) p = ps[0]; pen.graphics.curveTo(ps[i].x, ps[i].y, ps[i].x / 2 + p.x / 2, ps[i].y / 2+ p.y / 2); } pen.graphics.curveTo(ps[0].x, ps[0].y, ps[0].x/2+ps[1].x/2,ps[0].y/2+ps[1].y/2); ct.redMultiplier += vr; ct.greenMultiplier += vg; ct.blueMultiplier += vb; if (ct.redMultiplier > max) { ct.redMultiplier = max; vr = -Math.abs(vr); } if (ct.redMultiplier vr = Math.abs(vr); } if (ct.greenMultiplier > max) { ct.greenMultiplier = max; vg = -Math.abs(vg); } if (ct.greenMultiplier vg = Math.abs(vg); } if (ct.blueMultiplier > max) { ct.blueMultiplier = max; vb = -Math.abs(vb); } if (ct.blueMultiplier vb = Math.abs(vb); } bmd.colorTransform(bmd.rect, ct); bmd.draw(pen); } } } import flash.geom.Point; class Particle extends Point { public var vx:Number; public var vy:Number; public function Particle(x:Number,y:Number,vx:Number,vy:Number) { super(x, y); this.vx = vx; this.vy = vy; } } |
创造与魔法 安卓版v1.0.0750
创造与魔法是一款开放世界手游,在游戏中玩家可探索这个奇妙的世
创造与魔法修改版 最新版v1.0.0750
创造与魔法无限点券版是款探索冒险游戏,该款游戏的操作还是蛮自
战争与文明官方版本 安卓版v1.7.16
战争与文明是一款由上海邮通科技有限公司开发的战争策略游戏,这
迷你世界0元领皮肤无限迷你币版 最新安卓版v1.43.0
迷你世界0元购买皮肤版是这款开放沙盒冒险建造游戏的特殊破解版
创造与魔法无限经验版 安卓版v1.0.0750
创造与魔法无限经验版是款可以改造环境,整个游戏的自由度还是蛮