Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
slmjkdbtl committed Jul 25, 2023
1 parent 397190e commit 4c0445e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions src/kaboom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4062,7 +4062,9 @@ export default (gopt: KaboomOpt = {}): KaboomCtx => {

let spriteData: SpriteData | null = null
let curAnim: SpriteCurAnim | null = null
let curAnimDir: -1 | 1 | null = null // 1 - from small index to large index; -1 - reverse
// 1 - from small index to large index
// -1 - reverse
let curAnimDir: -1 | 1 | null = null
const spriteLoadedEvent = new Event<[SpriteData]>()

if (!src) {
Expand Down Expand Up @@ -4225,25 +4227,27 @@ export default (gopt: KaboomOpt = {}): KaboomCtx => {
curAnim.timer += dt() * this.animSpeed

if (curAnim.timer >= (1 / curAnim.speed)) {
curAnim.timer = 0

curAnim.timer = 0
this.frame += curAnimDir

if (this.frame < Math.min(anim.from, anim.to) || this.frame > Math.max(anim.from, anim.to)) {
if (this.frame < Math.min(anim.from, anim.to) ||
this.frame > Math.max(anim.from, anim.to)) {
if (curAnim.loop) {
if (curAnim.pingpong) {
this.frame -= curAnimDir
curAnimDir *= -1
this.frame += curAnimDir
this.frame += curAnimDir
} else {
this.frame = anim.from
}
} else {
this.frame -= curAnimDir
this.frame = anim.to
curAnim.onEnd()
this.stop()
}
}

}

},
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2615,7 +2615,7 @@ export interface GameObjRaw {
* Gather debug info of all comps.
*/
inspect(): GameObjInspect,
/**
/**
* Register an event that runs when the game obj is added to the scene.
*/
onAdd(action: () => void): EventController,
Expand Down

0 comments on commit 4c0445e

Please sign in to comment.