home *** CD-ROM | disk | FTP | other *** search
/ Champak 106 / Vol 106.iso / games / rain_for.swf / scripts / __Packages / smashing / Base.as next >
Encoding:
Text File  |  2010-04-12  |  1.7 KB  |  79 lines

  1. class smashing.Base
  2. {
  3.    var aT;
  4.    var last;
  5.    var currentWorld;
  6.    static var interval;
  7.    var bPlay = false;
  8.    function Base()
  9.    {
  10.       if(smashing.Base.interval != null)
  11.       {
  12.          clearInterval(smashing.Base.interval);
  13.          smashing.Base.interval = null;
  14.       }
  15.       this.aT = [];
  16.    }
  17.    function get playing()
  18.    {
  19.       return this.bPlay;
  20.    }
  21.    function play()
  22.    {
  23.       if(smashing.Base.interval == null)
  24.       {
  25.          this.bPlay = true;
  26.          this.last = getTimer();
  27.          smashing.Base.interval = setInterval(function(o)
  28.          {
  29.             o.update();
  30.          }
  31.          ,0,this);
  32.          this.currentWorld.onPlay();
  33.       }
  34.    }
  35.    function pause()
  36.    {
  37.       if(smashing.Base.interval != null)
  38.       {
  39.          this.bPlay = false;
  40.          clearInterval(smashing.Base.interval);
  41.          smashing.Base.interval = null;
  42.          this.currentWorld.onPause();
  43.       }
  44.    }
  45.    function update(o)
  46.    {
  47.       var _loc5_ = getTimer();
  48.       var _loc6_ = (_loc5_ - this.last) / 1000;
  49.       this.currentWorld.update(_loc6_);
  50.       this.last = _loc5_;
  51.       if(this.aT.length > 4)
  52.       {
  53.          var _loc4_ = undefined;
  54.          _loc4_ = 0;
  55.          var _loc3_ = 0;
  56.          while(_loc3_ < this.aT.length)
  57.          {
  58.             _loc4_ += this.aT[_loc3_];
  59.             _loc3_ = _loc3_ + 1;
  60.          }
  61.          _root.nDebug0 = _loc4_ / this.aT.length;
  62.          this.aT = [];
  63.       }
  64.       this.aT.push(_loc6_);
  65.    }
  66.    function setWorld(oWorld)
  67.    {
  68.       if(oWorld != null)
  69.       {
  70.          this.currentWorld.onExit();
  71.          this.currentWorld = oWorld;
  72.          this.currentWorld.onEnter();
  73.       }
  74.    }
  75.    static function hey()
  76.    {
  77.    }
  78. }
  79.