SPRITE_X_POSITION()

SPRITE_X_POSITION(N)

RETURNS THE X COORDINATE OF THE SPRITE NUMBER N

  • Type: Function
  • Parameter: 1
  • Group: SPRITE

ACTION

The function SPRITE_X_POSITION(N) returns the X coordinate of the SPRITE number N.

The coordinates X and Y of a SPRITE are "screen" coordinates in the SCENE2D : the X value of the coordinate is the horizontal position on the SCENE2D that counts from left to right. The Y value of the coordinate is the vertical position on the SCENE2D that counts from top to bottom.

The coordinates (0,0) are the coordinates of the upper left corner of the SCENE2D.

SYNTAX: Result=SPRITE_X_POSITION(N)

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

USE

  • The function SPRITE_X_POSITION() is used to know the horizontal position of a SPRITE on its SCENE2D.

ERROR

  • If number N is not a correct expression.
  • If number N exceeds the allowed maximum number of SPRITE objects.
  • If number N is not greater than 0.
  • If the SPRITE number N does not exist.

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

rem afficher la position du SPRITE

print sprite_x_position(1)

print sprite_y_position(1)

SEE ALSO

SPRITE_Y_POSITION()

SPRITE_X_POSITION

SPRITE_Y_POSITION

SPRITE_POSITION