*sp | Pointer for sprite structure |
n | Sprite number |
pri | Priority |
attr | Attribute |
The followings can be set as attribute:
NJD_SPRITE_ANGLE | Validate texture rotation. |
NJD_SPRITE_COLOR | Validate texture color operation. Values set to njSetConstantMaterial() used for color data. |
NJD_SPRITE_HFLIP | Reverse texture horizontally (L<->R) |
NJD_SPRITE_VFLIP | Reverse texture vertically (Up<->Down) |
NJD_SPRITE_HVFLIP | Reverse texture horizontally and vertically. |
NJD_SPRITE_ALPHA | Set if transparency or extract texture is used. |
The following uses two 256x256 textures, divides each texture into four patterns and makes 8 texture animation patterns. NJS_TEXANIM anim[] = { { 128,128, 64, 64, 0, 0,127,127, 0, 0 }, { 128,128, 64, 64,128, 0,255,127, 0, 0 }, { 128,128, 64, 64, 0,128,127,255, 0, 0 }, { 128,128, 64, 64,128,128,255,255, 0, 0 }, { 128,128, 64, 64, 0, 0,127,127, 1, 0 }, { 128,128, 64, 64,128, 0,255,127, 1, 0 }, { 128,128, 64, 64, 0,128,127,255, 1, 0 }, { 128,128, 64, 64,128,128,255,255, 1, 0 }, }; main() { NJS_SPRITE sprite; /* Initial setup of each type */ sprite.tlist = &texlist; sprite.tanim = anim; sprite.ang = 0x4000; sprite.sx = 1.0f; sprite.sy = 1.0f; sprite.p.x = 320.0f; sprite.p.y = 240.0f; njLoadTexture(&texlist); njDrawSprite2D( &sprite, 2, -150.f, NJD_SPRITE_ANGLE ); : }