LoadSprite

Top  Previous  Next

Syntax

POINTER = LoadSprite(filename as STRING,OPT width as INT,OPT height as INT,OPT frames as INT, OPT bSystemRam as INT)

Description

Loads a sprite from an image file or program resources.

Parameters

filename - File name or resource ID to load sprite from.

width - Optional width of sprite

height - Optional height of sprite

frames - Optional number of frames the image contains

bSystemRam - Optional. If TRUE then sprite is loaded into system memory instead of video memory.

Return value

A pointer to the loaded sprite.

Remarks

LOADSPRITE can handle bitmap, JPEG, and any other image type displayable in Internet Explorer. A screen must be opened before any sprites can be loaded and you must free all sprites with the FREESPRITE function before you close the screen.

If your image consists of a row of frames then you can just specify the number of frames and LoadSprite will calculate the width and height.

If you know the width and height but the number of frames may vary you can specify just the width and height and the number of frames will be calculated automatically. If your image consists of many rows and columns of frame images you must specify width, height and the number of frames.

The optional bSystemRam parameter allows the sprite to be loaded into main system memory instead of video card memory. For alpha blending and rotozooming drawing modes this will result in a dramatic speed increase when displaying the sprite. All other drawing modes should use the default. Loading in system ram is also beneficial if you plan to make many copies of the sprite.

Images can be stored in your programs resources as a scalable image. The resource ID is a string identifier.

See Also: FREESPRITE

Example usage

MySprite = LOADSPRITE(GETSTARTPATH + "badguy.jpg", 0, 0, 10, TRUE)
goodguy = LOADSPRITE(GETSTARTPATH + "goodguy.jpg")
resource_sprite = LOADSPRITE("sprite7",24,24,10)