Advertisement
Masadow

Trailing circle

Dec 20th, 2013
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 1.10 KB | None | 0 0
  1. package character;
  2. import flixel.FlxSprite;
  3. import flixel.util.FlxSpriteUtil;
  4. import flixel.FlxG;
  5. import flixel.util.loaders.CachedGraphics;
  6. import flash.display.Graphics;
  7.  
  8. /**
  9.  * ...
  10.  * @author Masadow
  11.  */
  12. class Circle extends FlxSprite
  13. {
  14.     private var _timeleft : Float;
  15.    
  16.     public static function initGraphic()
  17.     {
  18.         //Prepare graphic
  19.         var graphic : CachedGraphics = FlxG.bitmap.create(16, 16, 0x0, true, "circle");
  20.         FlxSpriteUtil.flashGfx.clear();
  21.         FlxSpriteUtil.flashGfx.beginFill(0xFFFFFFFF);
  22.         FlxSpriteUtil.flashGfx.lineStyle(2, 0xFFFFFF, 0.5);
  23.         FlxSpriteUtil.flashGfx.drawCircle(8, 8, 8);
  24.         FlxSpriteUtil.flashGfx.endFill();
  25.         graphic.bitmap.draw(FlxSpriteUtil.flashGfxSprite);
  26.     }
  27.  
  28.     public function new(MakeGraphic : Bool = true)
  29.     {
  30.         super();
  31.  
  32.         loadGraphic("circle");
  33.        
  34.         visible = false;
  35.     }
  36.    
  37.     public function run(X : Float, Y : Float) {
  38.         x = X;
  39.         y = Y;
  40.         visible = true;
  41.         _timeleft = 0.5; //In seconds
  42.     }
  43.    
  44.     override public function update(): Void
  45.     {
  46.         super.update();
  47.  
  48.         if (_timeleft > 0 && (_timeleft -= FlxG.elapsed) < 0)
  49.         {
  50.             visible = false;
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement