KunoNoOni

VertEle

Apr 15th, 2012
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package
  2. {
  3.     import org.flixel.*;
  4.    
  5.     public class VertEle extends FlxSprite
  6.     {
  7.         private static var movingUp:Boolean = true;
  8.         private static var movingDown:Boolean = false;
  9.        
  10.         public function VertEle(X:Number=0,Y:Number=0)
  11.         {
  12.             super(X*16,Y*8)
  13.             loadGraphic(Registry.velevator,false,false,16,8);
  14.            
  15.             this.maxVelocity.y = 15;
  16.             this.drag.y = 400;
  17.            
  18.         }
  19.        
  20.         override public function update():void
  21.         {
  22.             FlxG.overlap(this,Registry.uwaypoints,goDown);
  23.             FlxG.overlap(this,Registry.dwaypoints,goUp);
  24.            
  25.             this.acceleration.y = this.maxVelocity.y;
  26.            
  27.             if(movingDown)
  28.             {
  29.                 this.velocity.y = -this.maxVelocity.y;
  30.             }
  31.             if(movingUp)
  32.             {
  33.                 this.velocity.y = this.maxVelocity.y;
  34.             }  
  35.            
  36.             super.update();
  37.         }  
  38.        
  39.         private function goDown(e:FlxSprite, w:FlxSprite):void
  40.         {
  41.             movingUp = false;
  42.             movingDown = true;
  43.         }
  44.        
  45.         private function goUp(e:FlxSprite, w:FlxSprite):void
  46.         {
  47.             movingUp = true;
  48.             movingDown = false;
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment