Source: extras/getGlobalPosition.js

extras/getGlobalPosition.js

  1. import * as core from '../core';
  2. /**
  3. * Returns the global position of the displayObject. Does not depend on object scale, rotation and pivot.
  4. *
  5. * @method getGlobalPosition
  6. * @memberof PIXI.DisplayObject#
  7. * @param {Point} point - the point to write the global value to. If null a new point will be returned
  8. * @param {boolean} skipUpdate - setting to true will stop the transforms of the scene graph from
  9. * being updated. This means the calculation returned MAY be out of date BUT will give you a
  10. * nice performance boost
  11. * @return {Point} The updated point
  12. */
  13. core.DisplayObject.prototype.getGlobalPosition = function getGlobalPosition(point = new core.Point(), skipUpdate = false)
  14. {
  15. if (this.parent)
  16. {
  17. this.parent.toGlobal(this.position, point, skipUpdate);
  18. }
  19. else
  20. {
  21. point.x = this.position.x;
  22. point.y = this.position.y;
  23. }
  24. return point;
  25. };