home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Classicos / smashout.swf / scripts / __Packages / GDK / Node.as < prev    next >
Encoding:
Text File  |  2005-11-09  |  2.8 KB  |  124 lines

  1. class GDK.Node extends GDK.Generic
  2. {
  3.    var onCollision;
  4.    var world;
  5.    var onMove;
  6.    var children;
  7.    var target;
  8.    static var COLLISION_OK = 1;
  9.    static var COLLISION_CANCEL = 2;
  10.    static var COLLISION_SKIP_EVENT = 4;
  11.    var className = "Node";
  12.    var renderable = true;
  13.    var x = 0;
  14.    var y = 0;
  15.    var z = 0;
  16.    var collisionMask = 0;
  17.    function Node()
  18.    {
  19.       super();
  20.    }
  21.    function checkCollisionList(objects, flag, options, maxCol)
  22.    {
  23.       if(maxCol == null)
  24.       {
  25.          maxCol = 1.7976931348623157e+308;
  26.       }
  27.       if(flag == null)
  28.       {
  29.          flag = this.collisionMask;
  30.       }
  31.       var _loc4_ = 0;
  32.       var _loc5_ = undefined;
  33.       var _loc2_ = objects.length;
  34.       while((_loc2_ = _loc2_ - 1) > -1)
  35.       {
  36.          if(objects[_loc2_] != this)
  37.          {
  38.             if((flag & objects[_loc2_].collisionMask) > 0)
  39.             {
  40.                if(_loc5_ = this.checkCollision(objects[_loc2_]))
  41.                {
  42.                   _loc4_ = _loc4_ + 1;
  43.                   if(!(_loc5_ & GDK.Node.COLLISION_SKIP_EVENT) && this.onCollision(objects[_loc2_],options) == GDK.Node.COLLISION_CANCEL || _loc4_ >= maxCol)
  44.                   {
  45.                      break;
  46.                   }
  47.                }
  48.             }
  49.          }
  50.       }
  51.       return _loc4_;
  52.    }
  53.    function checkCollision(obj)
  54.    {
  55.       return false;
  56.    }
  57.    function moveTo(x, y, z)
  58.    {
  59.       this.moveBy(x - this.x,y - this.y,z - this.z);
  60.    }
  61.    function moveBy(x, y, z)
  62.    {
  63.       if(x || y || z)
  64.       {
  65.          this.x += x;
  66.          this.y += y;
  67.          this.z += z;
  68.          this.positionChanged(x,y,z);
  69.       }
  70.    }
  71.    function moveToGlobally(x, y, z)
  72.    {
  73.    }
  74.    function positionChanged(xShift, yShift, zShift)
  75.    {
  76.       this.world.onObjectMoved(this);
  77.       this.onMove();
  78.       this.queueForDisplay();
  79.    }
  80.    function pv_positionChanged(xShift, yShift, zShift)
  81.    {
  82.       var _loc2_ = this.children.length;
  83.       while((_loc2_ = _loc2_ - 1) > -1)
  84.       {
  85.          this.children[_loc2_].moveBy(xShift,yShift,zShift);
  86.       }
  87.       this.queueForDisplay();
  88.    }
  89.    function display()
  90.    {
  91.       this.setDisplay.apply(this,arguments);
  92.       delete this.queueForDisplay;
  93.    }
  94.    function setDisplay()
  95.    {
  96.       this.target._x = this.x;
  97.       this.target._y = this.y;
  98.    }
  99.    function getUpdates()
  100.    {
  101.       this.world.updateList.addMember(this);
  102.    }
  103.    function cancelUpdates()
  104.    {
  105.       this.world.updateList.removeMember(this);
  106.    }
  107.    function onBeginParent()
  108.    {
  109.       if(!this.affectChildren)
  110.       {
  111.          return undefined;
  112.       }
  113.       this.positionChanged = this.pv_positionChanged;
  114.    }
  115.    function onEndParent()
  116.    {
  117.       delete this.positionChanged;
  118.    }
  119.    function timelineUpdate()
  120.    {
  121.       this.queueForDisplay();
  122.    }
  123. }
  124.