Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts;
- /**
- * ...
- * @author SadiQ
- */
- import com.stencyl.Engine;
- import com.stencyl.graphics.BitmapWrapper;
- import com.stencyl.utils.Utils;
- import openfl.display.Bitmap;
- import openfl.display.BitmapData;
- import openfl.display.Shape;
- import openfl.filters.BitmapFilter;
- import openfl.filters.BlurFilter;
- import openfl.geom.Matrix;
- import openfl.geom.Point;
- import scripts.Particle2D;
- import com.stencyl.graphics.G;
- import com.stencyl.behavior.Script;
- import com.stencyl.behavior.Script.*;
- class Particle2D
- {
- public var x:Float;
- public var y:Float;
- public var vx:Float;
- public var vy:Float;
- public var color:Int;
- public var radius:Int;
- public var alpha:Float;
- var bd:BitmapData;
- var shape:Shape;
- var bw:BitmapWrapper;
- var splashGravity:Float;
- public function new(x:Float = 0, y:Float = 0, vx:Float = 0, vy:Float = 0, color:Int = 0, radius:Int = 5, alpha:Float = 0.5, splashGravity:Float = 0.6)
- {
- this.splashGravity = splashGravity;
- this.x = x;
- this.y = y;
- this.vx = vx;
- this.vy = vy;
- this.color = color;
- this.radius = radius;
- this.alpha = alpha;
- var width = this.radius*2;
- bd = new BitmapData(width, width,true, 0);
- var matrix:Matrix = new Matrix();
- shape = new Shape();
- shape.graphics.beginFill(this.color, this.alpha);
- shape.graphics.drawCircle(this.radius, this.radius, this.radius / 2);
- shape.graphics.endFill();
- bd.draw(shape);
- bw = new BitmapWrapper(new Bitmap(this.bd));
- attachImageToHUD(bw, Std.int(this.x), Std.int(this.y));
- trace (alpha);
- }
- public function update()
- {
- vy += splashGravity;
- vx *= 0.99;
- vy *= 0.99;
- x += vx;
- y += vy;
- bw.x = x;
- bw.y = y;
- }
- public function dispose()
- {
- removeImage(bw);
- bd = null;
- shape = null;
- bw = null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement