SPRITE

SPRITE N

CREATES A SPRITE AND GIVES IT NUMBER N AS REFERENCE

  • Type: Command
  • Parameter: 1
  • Group: SPRITE

ACTION

The command SPRITE creates a SPRITE object, that is a picture which can be moved on the picture of a SCENE2D without disturbing it.

A SPRITE owns a transparent color : the black color, it means that the black parts of the SPRITE are not displayed on the SCENE2D, making visible the background picture of the SCENE2D.

A SPRITE can receive a picture by the command SPRITE_FILE_LOAD and can be moved, deleted, hidden, showed... with the appropriated commands. When created, it is placed in (0,0) of a SCENE2D.

A SCENE2D and SPRITES are the basis of 2D video games.

Remark 1: by default, the SPRITE is created on the first created SCENE2D, but another SCENE2D can be used. For that, create a new SCENE2D, and send it all the commands by SPRITE_TARGET_IS before creating the SPRITE.

Remark 2: after creating a SPRITE, the normal way is to load a picture (file in BMP format) in the SPRITE by command SPRITE_FILE_LOAD.

SYNTAX: SPRITE N

  • N = number of SPRITE (integer or real). Must be greater than 0 and less than or equal to the allowed maximum number of SPRITE objects.

USE

  • The command SPRITE is used to create a SPRITE object in a SCENE2D, before loading a picture by SPRITE_FILE_LOAD.

ERROR

  • If number N is not a correct expression.
  • If number N exceeds the allowed maximum number of SPRITE objects.
  • If number N is less than or equal to 0.
  • If number N is already used for another SPRITE.
  • If no SCENE2D is created.

EXAMPLE

rem create a 2D world number 1

scene2d 1

rem load a background picture

file_load 1,"city.bmp"

rem create a SPRITE number 1

sprite 1

rem load a picture to the SPRITE

sprite_file_load 1,"alien.bmp"

rem place the SPRITE on the SCENE2D

sprite_x_position 1,150

sprite_y_position 1,250

SEE ALSO

SCENE2D

SPRITE

SPRITE_CREATE_HIDE

SPRITE_CREATE_SHOW

SPRITE_DELETE

SPRITE_DELETE_ALL

SPRITE_FILE_LOAD

SPRITE_IMAGE_LOAD

SPRITE_SHOW

SPRITE_SHOW_ALL

SPRITE_HIDE

SPRITE_HIDE_ALL

SPRITE_POSITION

SPRITE_X_POSITION

SPRITE_Y_POSITION

SPRITE_SCALE

SPRITE_X_SCALE

SPRITE_Y_SCALE

SPRITE_TARGET_IS

SPRITE_EXISTS()

SPRITE_X_POSITION()

SPRITE_Y_POSITION()