1 Reply Latest reply on May 3, 2011 12:12 PM by Ned Murphy

    Putting limits to my MC movement

    sora908

      var gpause = false;
      var timer = 6;
      var lives = 3;
      var score = 0;
      var nrEnemies = 3;

       

      for (i = 3; i < nrEnemies; i++)
      {
          _root.Enemy.duplicateMovieClip("Enemy" + i, _root.getNextHighestDepth());
      }

       

      var i=0;

       

      this.onEnterFrame = function()
      {
      if (!gpause)
      {
      timer++;
      if (Key.isDown(Key.RIGHT))
      {
      Ship._x += 25;
      } else if (Key.isDown(Key.LEFT))
      {
      Ship._x -= 25;
      } else if (Key.isDown(Key.UP))
      {
      Ship._y -= 25;
      } else if (Key.isDown(Key.DOWN))
      {
      Ship._y += 25;
      }
      if (Key.isDown(Key.SPACE))
      {
          i++;
          if(timer>=6)
          {
          _root.attachMovie("Bullet", "Bullet" + i, _root.getNextHighestDepth());
          _root["Bullet" + i]._x = Ship._x + 2;
          _root["Bullet" + i]._y = Ship._y;
          var shoot_sound = new Sound();
          shoot_sound.attachSound("shoot");
          shoot_sound.start();
          timer=0;
          }
          if (Key.isDown(Key.SHIFT))
          {
              if (gpause)
              { gpause = false;
              } else if (!gpause)
              {
              gpause = true;
              }
              }
          }
      }
      }

       

       

      I need help putting limits onto my movement my screen size is 550 by 400 so please help thank you.