SpriteSheet, spriteHeight and spriteWidth shouldn't be a must
ufukbakan opened this issue · comments
While defining a spritesheet like this:
SpriteSheet.fromImageSource({
image: assetImg,
grid: {
columns: N,
rows: M,
spriteHeight: assetImg.height / M,
spriteWidth: assetImg.width / N
}
});
spriteHeight and spriteWidth can be calculated using columns and rows info. Its just image.height / M
and image.width / N
,
you may include spacing calculation too but i generally have zero margin between sprites, so i think defining spriteHeight and spriteWidth should be optional not a must, we can define default values using calculations.
@ufukbakan Good point, I'll look into this!
This issue hasn't had any recent activity lately and is being marked as stale automatically.
@ufukbakan One issue with automatically calculating the sprite width/height is that the image.width
and image.height
aren't available until after the image is loaded.
I didn't realize this until I tried it locally. I do like the idea (simpler args are definitely better). There might be a way to make this type of thing work but I'll need to noodle about the API to make it work.
Closing this for now, willing to re-open if a new API idea to allow this is thought of