FOR THE VERSION 0.9.28
PART 4 - SCENE2D AND SPRITES
A SPRITE is a picture which can
be moved on a SCENE2D without disturbing it, the
black color is said "transparent".
A SPRITE must be created.
When it exists, it can then receive a picture (in BMP format), be moved, scaled,
hidden, showed again, destroyed.
For all the following commands, N is the number of the SPRITE.
SPRITE N | Creates the SPRITE number N in the "targeted" SCENE2D. |
SPRITE_CREATE_SHOW |
The next created SPRITEs will be visible |
SPRITE_CREATE_HIDE |
The next created SPRITEs will not be visible |
The "targeted" SCENE2D
is the system object which displays SPRITEs.
It is:
- the only existing SCENE2D if there is only one SCENE2D,
- the first created SCENE2D if there are several SCENE2Ds and no one has been designated as "target",
- The SCENE2D which has been designated as a "target" by the command SPRITE_TARGET_IS if there are several SCENE2Ds.
SPRITE_FILE_LOAD N, F | Loads into the SPRITE number N the picture (BMP) from the file F |
SPRITE_IMAGE_LOAD N1, N2 | Loads into the SPRITE number N1 the picture from the system object number N2. |
The file F is defined either with an absolute path, or relative to the current directory.
SPRITE_TEXT N, T | The SPRITE
number N displays the text T. The text is displayed with font, size, color and style defined for the SCENE2D. |
SPRITE_BRIGHTNESS N,V | Changes the brigthness of SPRITE number N. |
SPRITE_CONTRAST N,V | Changes the contrast of SPRITE number N. |
SPRITE_GAMMA N,V | Changes the gamma of SPRITE number N. |
For the 3 commands, V must be between -128 and 127
Every time a command is executed:
- if V=0, the picture remains unchanged,
- if V<0, its brightness or contrast or gamma decreases,
- if V>0, its brightness or contrast or gamma increases.
SPRITE_DELETE N | Deletes the SPRITE number N. |
SPRITE_SHOW N | Shows the SPRITE number N. |
SPRITE_HIDE N |
Hides the SPRITE number N. |
SPRITE_SHOW_ALL | Shows all the SPRITE. |
SPRITE_HIDE_ALL | Hides all the SPRITE. |
The default state of a SPRITE when created is: visible.
SPRITE_X_POSITION N, X | Set X-coordinate of the SPRITE number N. |
SPRITE_Y_POSITION N, Y | Set Y-coordinate of the SPRITE number N. |
SPRITE_POSITION N, X, Y | Set X and Y-coordinates of the SPRITE number N. |
The position of a SPRITE is the position of its upper left corner of its picture, it is expressed in pixels.
The X and Y coordinates are related to the SCENE2D to which the SPRITE belongs, and are "screen" coordinates:
- the origin (0,0) is the upper left corner of the SCENE2D
- the X-axis is the horizontal axis from the origin: X is more and more positive when we move to the right
- the Y-axis is the vertical axis from the origin: Y is more and more positive when we move to the bottom
SPRITE_X_SCALE N, CX | Shrinks or stretches the width
of the SPRITE number N. Shrinks if CX <1, stretches if CX > 1 |
SPRITE_Y_SCALE N, CY | Shrinks or stretches the height
of the SPRITE number N. Shrinks if CY <1, stretches if CY > 1 |
SPRITE_SCALE N, CX, CY | Shrinks or stretches the width and height of the SPRITE number N. |
SPRITE_X_POSITION(N) | Returns the X-coordinate of the SPRITE number N. |
SPRITE_Y_POSITION(N) | Returns the Y-coordinate of the SPRITE number N. |
NUMBER_SPRITES | Returns the number of SPRITEs. |
SPRITE_EXISTS(N) |
Returns 1 if the SPRITE number N exists, 0 otherwise |
Last update: June 25, 2018