Friday, June 16, 2017

c++ - How can I handle sprite sheets with nonuniform sprite dimensions?


For a spritesheet with non-uniform sprite dimensions, how can I get the bounding-rectangles for each individual sprite (i.e. the blue boxes in the following image / I only drew a few examples)?


What I would like to determine are: offset_x, offset_y, width, height


enter image description here


So far, I have only used spritesheets on which all sprites have identical dimensions. In that case, one simply needs to specify the x- and y-offset to get a particular sprite. However, for spritesheets of non-uniform dimensions this doesn't work.


EDIT: Having read through the comments and answers, I rephrased my question to make it more inclusive wrt. the actual process of using a spritesheet in a game. Previously, the question contained the points why people produce spritesheets of non-uniform dimensions and how I can deal with that.




No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...