Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Get the position of a DisplayObject relative to another DisplayObject or the stage
- *
- * @param [parent] {DisplayObject} The DisplayObject to calculate the relative position to
- * @param [position] {Point} The position of the precedent DisplayObject in the recursive chain
- * @return {Point} A point object representing the position of this object relative a parent or the stage
- */
- PIXI.DisplayObject.prototype.getRelativePosition = function(parent,position){
- var position = position || new PIXI.Point();
- var parent = parent || null;
- position.x += this.x;
- position.y += this.y;
- if(this.parent !== null && this.parent !== parent && this !== parent)
- {
- return this.parent.getRelativePosition(parent,position);
- }
- return position;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement