Sprite
Info
Dependencies:
- PermMem
Implementation:
Sprite.d on GitHub
Sprite package implements functions for working with 2D sprites.
Initialization
Initialize with LeGo_Sprite
flag.
Functions
Sprite_Create
Sprite_Create
Creates a sprite. The dimensions are in virtual coordinates.
var int x
X position of sprite (virtual)var int y
Y position of sprite (virtual)var int width
Width of sprite (virtual)var int height
Height of sprite (virtual)var int color
Color of sprite (in RGBA format)var string tex
Name of the sprite texture
Return value
The function returns the handle of the created sprite.
Sprite_CreatePxl
Sprite_CreatePxl
Creates a sprite. The dimensions are in pixels.
var int x
X position of sprite (pixels)var int y
Y position of sprite (pixels)var int width
Width of sprite (pixels)var int height
Height of sprite (pixels)var int color
Color of sprite (in RGBA format)var string tex
Name of the sprite texture
Return value
The function returns the handle of the created sprite.
Sprite_Render
Sprite_Render
Renders a sprite on a screen (must be visible first).
var int h
Handle of the sprite
Sprite_SetVisible
Sprite_SetVisible
Sets the visibility of a sprite.
var int h
Handle of the spritevar int visible
Visibility flag (0 for invisible, 1 for visible)
Sprite_SetPrio
Sprite_SetPrio
Sets the priority of a sprite. The higher the priority, the closer the sprite is to the camera.
var int h
Handle of the spritevar int prio
Priority of the sprite
Sprite_Scale
Sprite_Scale
Scales a sprite.
var int h
Handle of the spritevar int x
X scale factor (as ikarus float)var int y
Y scale factor (as ikarus float)
Sprite_SetWidth
Sprite_SetWidth
Sets the width of a sprite in virtual coordinates.
var int h
Handle of the spritevar int w
Width of the sprite in virtual coordinates
Sprite_SetWidthPxl
Sprite_SetWidthPxl
Sets the width of a sprite in pixels.
var int h
Handle of the spritevar int w
Width of the sprite in pixels
Sprite_SetHeight
Sprite_SetHeight
Sets the height of a sprite in virtual coordinates.
var int h
Handle of the spritevar int hg
Height of the sprite in virtual coordinates
Sprite_SetHeightPxl
Sprite_SetHeightPxl
Sets the height of a sprite in pixels.
var int h
Handle of the spritevar int hg
Height of the sprite in pixels
Sprite_SetDim
Sprite_SetDim
Sets the dimensions of a sprite in virtual coordinates.
var int h
Handle of the spritevar int w
Width of the sprite in virtual coordinatesvar int hg
Height of the sprite in virtual coordinates
Sprite_SetDimPxl
Sprite_SetDimPxl
Sets the dimensions of a sprite in pixels.
var int h
Handle of the spritevar int w
Width of the sprite in pixelsvar int hg
Height of the sprite in pixels
Sprite_SetPos
Sprite_SetPos
Sets the position of a sprite in virtual coordinates.
var int h
Handle of the spritevar int x
X position of the sprite (virtual)var int y
Y position of the sprite (virtual)
Sprite_SetPosPxl
Sprite_SetPosPxl
Sets the position of a sprite in pixels.
var int h
Handle of the spritevar int x
X position of the sprite (pixels)var int y
Y position of the sprite (pixels)
Sprite_SetPosPxlF
Sprite_SetPosPxlF
Sets the position of a sprite in pixels (floating point).
var int h
Handle of the spritevar int xf
X position of the sprite (pixels but as a float)var int yf
Y position of the sprite (pixels but as a float)
Sprite_SetColor
Sprite_SetColor
Sets the color of a sprite.
var int h
Handle of the spritevar int col
Color of the sprite (in RGBA format)
Sprite_SetVertColor
Sprite_SetVertColor
Sets the color of a vertex in a sprite.
var int h
Handle of the spritevar int vert
Index of the vertex (0-3)var int col
Color of the vertex (in RGBA format)
Sprite_SetUV
Sprite_SetUV
Sets the UV coordinates of a sprite.
var int h
Handle of the spritevar int x0
X coordinate of the top-left UVvar int y0
Y coordinate of the top-left UVvar int x1
X coordinate of the bottom-right UVvar int y1
Y coordinate of the bottom-right UV
Sprite_SetVertUV
Sprite_SetVertUV
Sets the UV coordinates of a vertex in a sprite.
var int h
Handle of the spritevar int vert
Index of the vertex (0-3)var int x
X coordinate of the UVvar int y
Y coordinate of the UV
Sprite_Rotate
Sprite_Rotate
Rotates a sprite by a given angle in degrees.
var int h
Handle of the spritevar int r
Rotation angle in degrees
Sprite_RotateR
Sprite_RotateR
Rotates a sprite by a given angle in radians.
var int h
Handle of the spritevar int r
Rotation angle in radians
Sprite_SetRotation
Sprite_SetRotation
Sets the rotation of a sprite in degrees.
var int h
Handle of the spritevar int r
Rotation angle in degrees
Sprite_SetRotationR
Sprite_SetRotationR
Sets the rotation of a sprite in radians.
var int h
Handle of the spritevar int r
Rotation angle in radians
Sprite_SetRotationSC
Sprite_SetRotationSC
Sets the rotation of a sprite using sine and cosine values.
var int h
Handle of the spritevar int sin
Sine value of the rotationvar int cos
Cosine value of the rotation
Helper functions
SinCosApprox
SinCosApprox
Approximates sine and cosine values for a given angle. Keeps them in var int sinApprox
var int cosApprox;
variables.
var int angle
Angle in degrees