Methods


initWithTitle:width:height:
first
last
add:
remove:
delete:
place:behind:
addDeleted:
freeDeleted
freeClients
free
step
keyDown:
keyUp:
mouseMoveX:Y:
loadPPMFile:toImage:
destroyImage:
clock

add:

- ( Sprite *) add:
        (Sprite *) newone;

Adds a sprite, newone, to the sprite list, and returns it.


addDeleted:

- ( Sprite *) addDeleted:
        (Sprite *) newone;

Adds a sprite, newone, to the list of sprites to be deleted. Sprites are deleted on every frame update if there are any in the list.


clock

- ( unsigned int ) clock;

Returns the number of milliseconds between the application start and the last frame update. This value is updated by -step once per frame update.


delete:

- ( Sprite *) delete:
        (Sprite *) oldone;

Removes a sprite, oldone, from the sprite list, and adds it to the deleted list. Returns the sprite.


destroyImage:

- ( void ) destroyImage:
        (SpriteImage *) si;

Releases resources associated with the SpriteImage structure si, which should have been created with -loadPPMFile:toImage:, or another method which creates SpriteImages. Does not release the structure itself.


first

- ( Sprite *) first;

Returns the SpriteApp's first sprite.


free

- free;

Deallocates memory associated with this SpriteApp.


freeClients

- ( void ) freeClients;

Frees all sprites in the sprite list.


freeDeleted

- ( void ) freeDeleted;

Frees all sprites in the deleted list. Called once per frame update.


initWithTitle:width:height:

- ( id ) initWithTitle:
        (char *) t width:
        (unsigned int ) w height:
        (unsigned int ) h;

Initialises the SpriteApp and creates a display surface for it of size (w,h) with window title t. In a window system, creates a window for the SpriteApp.


keyDown:

- ( void ) keyDown:
        (int ) aKey;

Key press handler. Code of key pressed is aKey (it is an ASCII code, or one of the SC_Key values in SpriteApp.h). Subclasses may override to customise this behavior.


keyUp:

- ( void ) keyUp:
        (int ) aKey;

Key release handler. Code of key released is aKey (it is an ASCII code, or one of the SC_Key values in SpriteApp.h). Subclasses may override to customise this behavior.


last

- ( Sprite *) last;

Returns the SpriteApp's last sprite.


loadPPMFile:toImage:

- ( int ) loadPPMFile:
        (char *) fn toImage:
        (SpriteImage *) si;

Loads a PPM file for use in this SpriteApp (or sprites associated with it). Fills the SpriteImage struct pointed to by si with an image from the PPM/PNM file whose name is in fn.


mouseMoveX:Y:

- ( void ) mouseMoveX:
        (int ) x Y:
        (int ) y;

Mouse motion handler. Mouse position is (x,y). Note: Mouse buttons are keys and handled by -keyDown: and -keyUp:. Subclasses may override to customise this behavior.


place:behind:

- ( Sprite *) place:
        (Sprite *) aSprite behind:
        (Sprite *) anotherSprite;

Removes a sprite, aSprite, from the sprite list, and reinserts it behind anotherSprite. List order implies Z order. If anotherSprite is nil, adds the sprite to the end of the list, making it drawn last.

Returns aSprite.


remove:

- ( Sprite *) remove:
        (Sprite *) oldone;

Removes a sprite, oldone, from the sprite list, and returns it.


step

- ( void ) step;

Frame update function. Draws background, moves and renders sprites onto backbuffer, checks for and handles pending events. Should be called in a loop.

(Last Updated 7/27/2005)