##### Ninja Library - 2D Drawing Function

# njDrawSprite2D

Draws 2D sprite

### FORMAT

`

  void njDrawSprite2D( *sp, n, pri, attr )
  NJS_SPRITE *sp
  Int n
  Float pri
  Uint32 attr

`

### PARAMETER

  `*sp` | Pointer for sprite structure
  `n` | Sprite number
  `pri` | Priority
  `attr` | Attribute

### RETURN

  None

### DESCRIPTION

  Draws 2D sprite. Sprite can draw textures and its animations easily. Priority sets the Z value. Back is minus direction and its range is -1.0 thru -65535.0.

  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.

### EXAMPLE

      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 );
        	:
      }

### REFERENCE

  `njDrawSprite3D()
  njSetConstantMaterial()
  njLoadTexture()
  `

njDrawSprite2D

COPYRIGHT © SEGA ENTERPRISES, LTD., 1998,1999