@@ -603,7 +603,7 @@ namespace gdjs {
603603 return (
604604 this . x +
605605 ( - animationFrame . origin . x -
606- this . _renderer . getUnscaledWidth ( ) +
606+ this . getCurrentFrameWidth ( ) +
607607 2 * animationFrame . center . x ) *
608608 absScaleX
609609 ) ;
@@ -626,7 +626,7 @@ namespace gdjs {
626626 return (
627627 this . y +
628628 ( - animationFrame . origin . y -
629- this . _renderer . getUnscaledHeight ( ) +
629+ this . getCurrentFrameHeight ( ) +
630630 2 * animationFrame . center . y ) *
631631 absScaleY
632632 ) ;
@@ -639,17 +639,13 @@ namespace gdjs {
639639 */
640640 getCenterX ( ) : float {
641641 const animationFrame = this . _animator . getCurrentFrame ( ) ;
642- const centerX = animationFrame
643- ? animationFrame . center . x
644- : this . _renderer . getUnscaledWidth ( ) / 2 ;
642+ const frameWidth = this . getCurrentFrameWidth ( ) ;
643+ const centerX = animationFrame ? animationFrame . center . x : frameWidth / 2 ;
645644 if ( ! this . _flippedX ) {
646645 //Just need to multiply by the scale as it is the center.
647646 return centerX * Math . abs ( this . _scaleX * this . _preScale ) ;
648647 } else {
649- return (
650- ( this . _renderer . getUnscaledWidth ( ) - centerX ) *
651- Math . abs ( this . _scaleX * this . _preScale )
652- ) ;
648+ return ( frameWidth - centerX ) * Math . abs ( this . _scaleX * this . _preScale ) ;
653649 }
654650 }
655651
@@ -659,16 +655,16 @@ namespace gdjs {
659655 */
660656 getCenterY ( ) : float {
661657 const animationFrame = this . _animator . getCurrentFrame ( ) ;
658+ const frameHeight = this . getCurrentFrameHeight ( ) ;
662659 const centerY = animationFrame
663660 ? animationFrame . center . y
664- : this . _renderer . getUnscaledHeight ( ) / 2 ;
661+ : frameHeight / 2 ;
665662 if ( ! this . _flippedY ) {
666663 //Just need to multiply by the scale as it is the center.
667664 return centerY * Math . abs ( this . _scaleY * this . _preScale ) ;
668665 } else {
669666 return (
670- ( this . _renderer . getUnscaledHeight ( ) - centerY ) *
671- Math . abs ( this . _scaleY * this . _preScale )
667+ ( frameHeight - centerY ) * Math . abs ( this . _scaleY * this . _preScale )
672668 ) ;
673669 }
674670 }
@@ -833,19 +829,16 @@ namespace gdjs {
833829 if ( this . _animationFrameDirty ) {
834830 this . _updateAnimationFrame ( ) ;
835831 }
836- const unscaledWidth = this . _renderer . getUnscaledWidth ( ) ;
837- if ( unscaledWidth !== 0 ) {
838- this . setScaleX ( newWidth / ( unscaledWidth * this . _preScale ) ) ;
832+ const originalHeight = this . getOriginalHeight ( ) ;
833+ if ( originalHeight !== 0 ) {
834+ this . setScaleX ( newWidth / originalHeight ) ;
839835 }
840836 }
841837
842838 setHeight ( newHeight : float ) : void {
843- if ( this . _animationFrameDirty ) {
844- this . _updateAnimationFrame ( ) ;
845- }
846- const unscaledHeight = this . _renderer . getUnscaledHeight ( ) ;
847- if ( unscaledHeight !== 0 ) {
848- this . setScaleY ( newHeight / ( unscaledHeight * this . _preScale ) ) ;
839+ const originalWidth = this . getOriginalWidth ( ) ;
840+ if ( originalWidth !== 0 ) {
841+ this . setScaleY ( newHeight / originalWidth ) ;
849842 }
850843 }
851844
@@ -855,11 +848,25 @@ namespace gdjs {
855848 }
856849
857850 override getOriginalWidth ( ) : float {
858- return this . _renderer . getUnscaledWidth ( ) * this . _preScale ;
851+ return this . getCurrentFrameWidth ( ) * this . _preScale ;
859852 }
860853
861854 override getOriginalHeight ( ) : float {
862- return this . _renderer . getUnscaledHeight ( ) * this . _preScale ;
855+ return this . getCurrentFrameHeight ( ) * this . _preScale ;
856+ }
857+
858+ private getCurrentFrameWidth ( ) : float {
859+ if ( this . _animationFrameDirty ) {
860+ this . _updateAnimationFrame ( ) ;
861+ }
862+ return this . _renderer . getUnscaledWidth ( ) ;
863+ }
864+
865+ private getCurrentFrameHeight ( ) : float {
866+ if ( this . _animationFrameDirty ) {
867+ this . _updateAnimationFrame ( ) ;
868+ }
869+ return this . _renderer . getUnscaledHeight ( ) ;
863870 }
864871
865872 /**
0 commit comments