Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

Commit

Permalink
support anim pingpong without loop
Browse files Browse the repository at this point in the history
  • Loading branch information
slmjkdbtl committed Nov 15, 2023
1 parent a9c6b4c commit 543c373
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/kaboom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3811,9 +3811,22 @@ export default (gopt: KaboomOpt = {}): KaboomCtx => {
this.frame = anim.from
}
} else {
this.frame = anim.to
curAnim.onEnd()
this.stop()
if (curAnim.pingpong) {
const isForward = curAnimDir === Math.sign(anim.to - anim.from)
if (isForward) {
this.frame = anim.to
curAnimDir *= -1
this.frame += curAnimDir
} else {
this.frame = anim.from
curAnim.onEnd()
this.stop()
}
} else {
this.frame = anim.to
curAnim.onEnd()
this.stop()
}
}
}

Expand Down

0 comments on commit 543c373

Please sign in to comment.