home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Acao / midnightstrike1.swf / scripts / __Packages / com / neodelight / v2D / MoverShot.as < prev    next >
Encoding:
Text File  |  2007-04-02  |  1.5 KB  |  51 lines

  1. class com.neodelight.v2D.MoverShot extends com.neodelight.v2D.Mover
  2. {
  3.    var client;
  4.    var actAge;
  5.    var maxAge;
  6.    var dieOffscreen;
  7.    var screenPos;
  8.    var origin;
  9.    function MoverShot(client, config)
  10.    {
  11.       super(client);
  12.       this.client.freeMovement = true;
  13.       this.actAge = 0;
  14.       this.maxAge = com.neodelight.std.XMath.toNumber(config.maxAge);
  15.       this.dieOffscreen = Boolean(config.dieOffscreen);
  16.       if(config.moverWeight)
  17.       {
  18.          this.client.weight = com.neodelight.std.XMath.toNumber(config.moverWeight);
  19.       }
  20.       this.client.v.x = com.neodelight.std.XMath.toNumber(config.moverVx);
  21.       this.client.v.y = com.neodelight.std.XMath.toNumber(config.moverVy);
  22.    }
  23.    function move()
  24.    {
  25.       super.move();
  26.       if(this.maxAge)
  27.       {
  28.          this.actAge += _global.dt;
  29.          if(this.actAge >= this.maxAge)
  30.          {
  31.             this.client.die();
  32.          }
  33.       }
  34.       if(this.dieOffscreen)
  35.       {
  36.          if(this.screenPos.x < 0 || this.screenPos.x > _global.game.stageWidth || this.screenPos.y < 0 || this.screenPos.y > _global.game.stageHeight)
  37.          {
  38.             this.client.kill();
  39.          }
  40.       }
  41.    }
  42.    function getTotalBoundingRect()
  43.    {
  44.       this.client.totalBoundingRect.p0.x = this.origin.x;
  45.       this.client.totalBoundingRect.p0.y = this.origin.y;
  46.       this.client.totalBoundingRect.p1.x = this.origin.x;
  47.       this.client.totalBoundingRect.p1.y = this.origin.y;
  48.       return this.client.totalBoundingRect;
  49.    }
  50. }
  51.