replit / kaboom

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

Quad not working as expected #740

Closed atomos-social closed 1 year ago

atomos-social commented 1 year ago

Expected Behavior

The kaboom types indicate you can specify a quad in the sprite options (ie: sprite("name", { quad: quad(0, 0, 1, 1) }), which describes

The rectangular sub-area of the texture to render

I assume this means quad works like some kind of overflow or clipping in CSS.

Current Behavior

quad has no effect (or just scales the sprite) instead of rendering a sub-area.

Current Solutions

This was mentioned as a possible solution, but it doesn't seem to work for me

add([sprite("test"]).quad.h *= 0.5

Steps to Reproduce

Playground and code:

kaboom()

loadSprite("bean", "/sprites/bean.png")

add([
        // I expected the bean to be cut in half, but I see no visible changes
    sprite("bean", { quad: quad(0, 0, 0.5, 1) }),
    pos(center())
])

Output: image

Environment

{
    "devDependencies": {
        "typescript": "^5.0.2",
        "vite": "^4.4.0"
    },
    "dependencies": {
        "kaboom": "^3000.0.14"
    }
}

edit: added more context

slmjkdbtl commented 1 year ago

Fixed in 115613a