* update the bounding box for this shape. * @param {boolean} [absolute=true] - update the bounds size and position in (world) absolute coordinates * @returns {Bounds} this shape bounding box Rectangle object
(absolute = true)
| 775 | * @returns {Bounds} this shape bounding box Rectangle object |
| 776 | */ |
| 777 | updateBounds(absolute = true) { |
| 778 | if (this.isRenderable) { |
| 779 | const bounds = this.getBounds(); |
| 780 | |
| 781 | bounds.clear(); |
| 782 | if (this.autoTransform === true && !this.currentTransform.isIdentity()) { |
| 783 | // temporarily translate the matrix based on the anchor point |
| 784 | this.currentTransform.translate( |
| 785 | -this.width * this.anchorPoint.x, |
| 786 | -this.height * this.anchorPoint.y, |
| 787 | ); |
| 788 | bounds.addFrame(0, 0, this.width, this.height, this.currentTransform); |
| 789 | this.currentTransform.translate( |
| 790 | this.width * this.anchorPoint.x, |
| 791 | this.height * this.anchorPoint.y, |
| 792 | ); |
| 793 | } else { |
| 794 | bounds.addFrame(0, 0, this.width, this.height); |
| 795 | // translate the bounds based on the anchor point |
| 796 | bounds.translate( |
| 797 | -this.width * this.anchorPoint.x, |
| 798 | -this.height * this.anchorPoint.y, |
| 799 | ); |
| 800 | } |
| 801 | |
| 802 | if (absolute === true) { |
| 803 | const absPos = this.getAbsolutePosition(); |
| 804 | bounds.centerOn( |
| 805 | absPos.x + bounds.x + bounds.width / 2, |
| 806 | absPos.y + bounds.y + bounds.height / 2, |
| 807 | ); |
| 808 | } |
| 809 | return bounds; |
| 810 | } else { |
| 811 | // manage the case where updateBounds is called |
| 812 | // before the object being yet properly initialized |
| 813 | return super.updateBounds(absolute); |
| 814 | } |
| 815 | } |
| 816 | |
| 817 | /** |
| 818 | * return the renderable absolute position in the game world. The |
no test coverage detected