Skip to content

Commit

Permalink
fix #469 CounterClockwise rotation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jedeen committed Jul 25, 2015
1 parent 4fa47d6 commit 3004d23
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/engine/Actions/Action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,15 +411,15 @@ module ex.Internal.Actions {
break;
case RotationType.Clockwise:
this._direction = 1;
if (this._shortDistance >= 0) {
if (this._shortestPathIsPositive) {
this._distance = this._shortDistance;
} else {
this._distance = this._longDistance;
}
break;
case RotationType.CounterClockwise:
this._direction = -1;
if (this._shortDistance <= 0) {
if (!this._shortestPathIsPositive) {
this._distance = this._shortDistance;
} else {
this._distance = this._longDistance;
Expand Down
16 changes: 13 additions & 3 deletions src/spec/ActorSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,19 +325,29 @@ describe("A game actor", () => {
it('can be rotated to an angle at a speed via CounterClockwise', () => {
expect(actor.rotation).toBe(0);

actor.rotateTo(Math.PI / 2, Math.PI / 2, ex.RotationType.Clockwise);
actor.rotateTo(Math.PI / 2, Math.PI / 2, ex.RotationType.CounterClockwise);
actor.update(engine, 2000);

expect(actor.rotation).toBe(Math.PI);
expect(actor.rotation).toBe(-Math.PI);

actor.update(engine, 1000);
expect(actor.rotation).toBe(Math.PI / 2);
expect(actor.rotation).toBe(-3 * Math.PI / 2);

actor.update(engine, 500);
expect(actor.rotation).toBe(Math.PI / 2);
expect(actor.rx).toBe(0);

// rotating back to 0, starting at PI / 2
actor.rotateTo(0, Math.PI / 2, ex.RotationType.CounterClockwise);
actor.update(engine, 1000);
expect(actor.rotation).toBe(0);

actor.update(engine, 1);
expect(actor.rx).toBe(0);

});


// it('can be rotated to an angle by a certain time', ()=>{
// expect(actor.rotation).toBe(0);

Expand Down

0 comments on commit 3004d23

Please sign in to comment.