0
\$\begingroup\$

I have a sprite sheet that's 155 x 66 pixels that I use for my game's UI. I've seen many topics regarding rendering sprite sheets by using the number of pixels and dividing that by the number of sprites to figure out where the render the sprite from. The problem with this is that the buttons on the sprite sheet cannot perfectly aligned so I'm left with differently sized sprites on the sprite sheet.

Sprite sheet image

How do I render an irregular sprite sheet in SDL2?

\$\endgroup\$
2
  • 2
    \$\begingroup\$ Since there are gaps anyway why don't you realign the buttons do you got two distinctive columns, which asked you once again to use it as a simple sortie sheet? \$\endgroup\$
    – Mario
    Commented Oct 21, 2016 at 5:40
  • \$\begingroup\$ Still mumbling something about carts, camera work and staring. :P \$\endgroup\$
    – Mario
    Commented Oct 21, 2016 at 18:44

1 Answer 1

0
\$\begingroup\$

You basically have two options here:

  1. You realign the sprites in the sheet, and use regular spritesheet loading methods to access the source rects that you want to use for rendering.
  2. Hardcode the areas into your code or into a resource file. This way you won't have to realign the sprites, but you have to then manually maintain these values.

I would personally just go with option one, and try to always align the spritesheets on a grid.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .