#### Archived

This topic is now archived and is closed to further replies.

# Sprite Sheets

This topic is 5612 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I don't get how you could use one image of a bunch of different sprites with a black background, and use that one image of all the sprites to incorporate each sprite into a game individually. How does that work? [edited by - Krak on August 5, 2003 2:44:34 PM]

##### Share on other sites
Use the texture coordinates. For example, if you want to use a sprite that takes up the lower left quarter of the texture, set the texture coordinates to (0, 0) for the bottom left corner of the sprite and (0.5, 0.5) for the top right. If you had a grid of 4x4 sprites in the texture, the texture coords for the first row/column would go from 0 to 0.25, the second from 0.25 to 0.5 and so on.

##### Share on other sites
quote:
Original post by Anonymous Poster
Use the texture coordinates. For example, if you want to use a sprite that takes up the lower left quarter of the texture, set the texture coordinates to (0, 0) for the bottom left corner of the sprite and (0.5, 0.5) for the top right. If you had a grid of 4x4 sprites in the texture, the texture coords for the first row/column would go from 0 to 0.25, the second from 0.25 to 0.5 and so on.

So if I had a 5*5 sheet of sprites, would the second sprite in the top row be located at (0.1, 0.5) or something like that?

I''m not sure if I 100% understand this.

##### Share on other sites
The second sprite in the top row would be (0.2,0.8). In OpenGL texture coordinates go from bottom-left, to top-right, not top-left to bottom-right.

With a 5x5 sheet, each sprite takes 1/5 (or .2) of the texture. With an 8x8 sheet, each sprite takes 1/8 (or .125) of the texture. Etc. This assumes that the texture is completely filled with no unused space at the end (like with a 128x128 pixel image with only 4 16x16 sprites on it).

1. 1
2. 2
Rutin
19
3. 3
khawk
15
4. 4
5. 5
A4L
13

• 13
• 26
• 10
• 11
• 44
• ### Forum Statistics

• Total Topics
633743
• Total Posts
3013644
×