Skip to content

Commit

Permalink
💫 pause sway tween during upward movement
Browse files Browse the repository at this point in the history
  • Loading branch information
haliphax committed Oct 4, 2023
1 parent f27c8c5 commit 19abeee
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/avatar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,18 @@ export default class Avatar {
}

if (this.chute.visible) {
if (this.container.body.velocity.y > this.chuteGravity)
if (this.container.body.velocity.y > this.chuteGravity) {
this.container.body.velocity.y = this.chuteGravity;

if (this.swayTween!.paused) {
this.swayTween!.resume();
}
} else if (
this.container.body.velocity.y < this.chuteGravity &&
!this.swayTween!.paused
) {
this.swayTween!.pause();
}
} else if (body.y >= this.sprite.height) {
this.swayTween = this.sprite.scene.add.tween({
duration: 2000,
Expand Down

0 comments on commit 19abeee

Please sign in to comment.