home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Acao / batman_cobble.swf / scripts / frame_16 / DoAction_5.as < prev    next >
Encoding:
Text File  |  2006-06-13  |  1.5 KB  |  52 lines

  1. _global.cameraLogic = function()
  2. {
  3.    _root.frameCount = _root.frameCount + 1;
  4.    if(_root.frameCount > 15 && !_root.fpsSet)
  5.    {
  6.       this.tick = getTimer() - this.lastTime;
  7.       _root.FPS = int(1 / this.tick * 1000 * _root.frameCount);
  8.       _root.frameCount = 0;
  9.       this.lastTime = getTimer();
  10.    }
  11.    bgDiff = this.bg._x + this._x;
  12.    if(bgDiff > 0)
  13.    {
  14.       this.bg._x -= this.bg._width / 2;
  15.    }
  16.    else if(bgDiff < (- this.bg._width) / 2)
  17.    {
  18.       this.bg._x += this.bg._width / 2;
  19.    }
  20.    if(_root.playerDir > 0)
  21.    {
  22.       targetX = 125;
  23.    }
  24.    else
  25.    {
  26.       targetX = 475;
  27.    }
  28.    targetY = 300;
  29.    playerPositionX = _root.game.player._x + this._x;
  30.    playerPositionY = _root.game.player._y + this._y;
  31.    if(_root.game.player._x > _root.camMin && _root.game.player._x < _root.camMax)
  32.    {
  33.       if(Math.abs(playerPositionX - targetX) > 4)
  34.       {
  35.          ease = int((playerPositionX - targetX) / 10);
  36.          this._x -= ease;
  37.          this.bg._x += ease / 2;
  38.          _root.bgScroll += ease / 2;
  39.       }
  40.    }
  41.    if(_root.playerJumping)
  42.    {
  43.       this._y = (_root.camHeight - this.player._y) / _root.camJump;
  44.       this.bg._y = (this.player._y / 2 - _root.camHeight / 1.5) / _root.camJump - _root.camOffset;
  45.    }
  46.    else if(Math.abs(this._y + this.player._y - 150) > 1)
  47.    {
  48.       this._y += int(((_root.camHeight - this.player._y) / _root.camJump - this._y) / 4);
  49.       this.bg._y = int((this.player._y / 2 - _root.camHeight / 1.5) / _root.camJump) - _root.camOffset;
  50.    }
  51. };
  52.