Sprite Sheets?

Blitz3D Forums/Blitz3D Programming/Sprite Sheets?

En929(Posted 2012) [#1]
Does anybody here use sprite sheets for their game (whether it's 2D or 3D Blitz)? For example, in JavaScript, one can use just one big png file that would carry all of the different graphics and images that would ever be used throughout one’s entire game. Thus, I was wondering how would that work in Blitz?


Kryzon(Posted 2012) [#2]
Some ways you can use sheets.

Always go first with what's native. This would be using image-strips\sheets loaded with LoadAnimImage.
It can be a sheet if you span several rows of frames and not just make it a big, single row strip.
An image loaded with AnimImage has a frame property used with DrawImage (last parameter).

You can also fake this functionality by using DrawImageRect and changing the offsets of capture so you draw a specific frame you want. It'll preserve masking and collision detection.
Using DrawImageRect will most likely be slower than using native framed images.

The latter method is, however, the way you'll have to go when using pixel-perfect quads for 2D-in-3D graphics: controlling offsets of capture.
You see, 3D quads have four vertices, each with UV coordinates. If you control the UV values you can "slide" the texture and position a specific frame on the mesh.

You need to study how UV values and vertex handling work under Blitz3D to achieve this - some 2D-in-3D engines can handle this for you (potentially Draw3D, SpriteCandy, nSprite 2 and others).