replit / kaboom

💥 JavaScript game library
https://kaboomjs.com
MIT License
2.67k stars 228 forks source link

"Anim not found" error when using frame 0 as anim #711

Closed l8doku closed 1 year ago

l8doku commented 1 year ago

Version: 3000.0.0-beta.0 (applies to master, too)

I load a sprite like this:

loadSprite("marksteroid", "/sprites/marksteroid_sheet.png", {
    sliceX: 2,
    sliceY: 1,
    anims: {
        normal: 0,
        boost: 1,
    }
})

Where the first frame (0) is considered an anim by itself.

The code below has a check if(!anim) which works both for when anim isn't found and when anim is a literal number 0.

https://github.com/replit/kaboom/blob/master/src/kaboom.ts#L4342

So when an anim exists, the error is still thrown.

It can be reproduced here https://3000.kaboomjs.com/play?example=sprite if you replace the "idle" anim's dictionary with "idle": 0 .

slmjkdbtl commented 1 year ago

Thanks for reporting, fixed in https://github.com/replit/kaboom/commit/47347144ec9ca1078aab046cf9f8ec75dc9516a2!