From 9052e561e046b2a7ad9885aa4bab507b43b874cf Mon Sep 17 00:00:00 2001 From: Matt Baker Date: Thu, 25 Aug 2022 20:10:06 -0700 Subject: [PATCH] Fix bug in `actions.scaleTo` Previously if scaling only on the x-axis, the action would never complete. --- src/engine/Actions/Action/ScaleTo.ts | 2 +- src/spec/ActionSpec.ts | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/engine/Actions/Action/ScaleTo.ts b/src/engine/Actions/Action/ScaleTo.ts index 6835fbd27..17c63a5c3 100644 --- a/src/engine/Actions/Action/ScaleTo.ts +++ b/src/engine/Actions/Action/ScaleTo.ts @@ -61,7 +61,7 @@ export class ScaleTo implements Action { public isComplete(): boolean { return ( this._stopped || - (Math.abs(this._tx.scale.y - this._startX) >= (this._distanceX - 0.01) && + (Math.abs(this._tx.scale.x - this._startX) >= (this._distanceX - 0.01) && Math.abs(this._tx.scale.y - this._startY) >= (this._distanceY - 0.01)) ); } diff --git a/src/spec/ActionSpec.ts b/src/spec/ActionSpec.ts index ab5e87388..96ccbf1d5 100644 --- a/src/spec/ActionSpec.ts +++ b/src/spec/ActionSpec.ts @@ -1051,6 +1051,19 @@ describe('Action', () => { expect(actor.scale.x).toBe(1.5); expect(actor.scale.y).toBe(1.5); }); + + it('completes when scaling on the x-axis', () => { + expect(actor.scale.x).toBe(1); + + const scaleTo = new ex.ScaleTo(actor, 2, 1, 1, 1); + actor.actions.runAction(scaleTo); + expect(scaleTo.isComplete()).toBeFalse(); + + scene.update(engine, 1000); + expect(actor.scale.x).toBe(2); + expect(actor.scale.y).toBe(1); + expect(scaleTo.isComplete()).toBeTrue(); + }); }); describe('scaleBy', () => {