Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public function moveLR(d:String):void
  2.         {      
  3.             var direction:int = GameConstants.moveAmount;
  4.            
  5.             if (!moving) {
  6.                 snd.play();
  7.                 moving = true;
  8.             }
  9.            
  10.             // Which direction are we moving?      
  11.             if (d == "Left")
  12.             {
  13.                 direction *= -1;
  14.             }
  15.            
  16.             physicallyMove(direction);
  17.         }  
  18.        
  19.         private function physicallyMove(amount:int):void
  20.         {
  21.            
  22.             if (side == "Left")
  23.             {
  24.                 if (this.x < 70)
  25.                 {
  26.                     this.x = 70;
  27.                 }
  28.                 else if (this.x > (GameConstants.wallLeft - GameConstants.cannonWidth))
  29.                 {
  30.                     this.x = GameConstants.wallLeft - GameConstants.cannonWidth;
  31.                 }
  32.                 else {
  33.                     this.x += amount;
  34.                     this.assetWheel.play();
  35.                 }
  36.             }
  37.             else if (side == "Right")
  38.             {
  39.                 if (this.x > 1210)
  40.                 {
  41.                     this.x = 1210;
  42.                 }
  43.                 else if (this.x < (GameConstants.wallRight + GameConstants.cannonWidth))
  44.                 {
  45.                     this.x = GameConstants.wallRight + GameConstants.cannonWidth;
  46.                 }
  47.                 else {
  48.                     this.x += amount;
  49.                     this.assetWheel.play();
  50.                 }
  51.             }
  52.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement