Advertisement
monotone_doppler

Untitled

Apr 2nd, 2015
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 1.08 KB | None | 0 0
  1. package game;
  2.  
  3. import flash.media.SoundTransform;
  4. import starling.animation.Tween;
  5. import starling.core.Starling;
  6. import starling.display.MovieClip;
  7. import starling.display.Sprite;
  8. import starling.events.Event;
  9.  
  10. class Explosion extends Sprite
  11. {
  12.  
  13.     private var clip:MovieClip;
  14.    
  15.     public function new(name:String, ?fps:Float = 10)
  16.     {
  17.         super();
  18.        
  19.         this.clip = new MovieClip(Root.assets.getTextures("explosions/" + name), fps);
  20.        
  21.         var tween = new Tween(this, this.clip.numFrames / fps);
  22.         tween.animate("alpha", 0);
  23.         Starling.juggler.add(tween);
  24.        
  25.         this.clip.pivotX = this.clip.width / 2.0;
  26.         this.clip.pivotY = this.clip.height / 2.0;
  27.         this.clip.scaleX = 1 / 16.0;
  28.         this.clip.scaleY = 1 / 16.0;
  29.         this.clip.smoothing = 'none';
  30.         this.clip.loop = false;
  31.         this.clip.addEventListener(Event.COMPLETE, function() {
  32.             this.removeFromParent();
  33.             Starling.juggler.remove(tween);
  34.             this.dispose();
  35.         });
  36.         this.addChild(this.clip);
  37.        
  38.         Starling.juggler.add(this.clip);
  39.        
  40.         Root.assets.playSound("Explosion1", 0, 0, Root.sfxTransform(0.65));
  41.        
  42.        
  43.     }
  44.    
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement