Name
SPRITE -- preload a sprite for later use (V2.0)
Synopsis
@SPRITE id, filename$[, table]
Function
This preprocessor command preloads the sprite specified in filename$ and keeps it under the identifier id.

Supported image formats are PNG, JPEG, BMP, IFF ILBM, and some more depending on the platform Hollywood is running on. Starting with Hollywood 4.5, @SPRITE can also open animation formats (IFF ANIM, GIF ANIM, uncompressed AVIs or AVIs using Motion JPEG compression) and convert these animations into a sprite directly.

The third argument is optional. It is a table that can be used to set further options for the loading operation. The following fields of the table can be used:

Transparency:
This field can be used to specify a color in RGB notation that shall be made transparent in the sprite.

LoadAlpha:
Set this field to True if the alpha channel of the image shall be loaded, too. Please note that not all pictures have an alpha channel and that not all picture formats are capable of storing alpha channel information. It is suggested that you use the PNG format if you need alpha channel data. This field defaults to False.

Link:
Set this field to False if you do not want to have this sprite linked to your executable/applet when you compile your script. This field defaults to True which means that the sprite is linked to your to your executable/applet when Hollywood is in compile mode.

X, Y, Width, Height, Frames, FPR:
This lot of fields can be used to fine-tune the loading operation. You can use these fields to make @SPRITE create a sprite with multiple frames from a single picture. Width and Height define the dimensions for the sprite and Frames specifies how many frames @SPRITE shall read from the source image. If the frames are aligned in multiple rows in the source image, you will also have to pass the argument FPR (stands for frames per row) to tell @SPRITE how many frames there are in each row. Finally, you can tell @SPRITE where in the image it should start scanning by specifying the fields X and Y (they both default to 0). @SPRITE will then start off at position X and Y and read Frames number of images with the dimensions of Width by Height from the picture specified by filename$. After it has read FPR number of images, it will advance to the next row. All of these fields can only be used if you specify an image file in filename$. If you specify an anim file, they are ignored.

Loader:
This tag allows you to specify one or more format loaders that should be asked to load this sprite. This must be set to a string containing the name(s) of one or more loader(s). Defaults to default. See Loaders and adapters for details. (V6.0)

Adapter:
This tag allows you to specify one or more file adapters that should be asked to open the specified file. This must be set to a string containing the name(s) of one or more adapter(s). Defaults to default. See Loaders and adapters for details. (V6.0)

LoadTransparency:
If this tag is set to True, the monochrome transparency of the image will be loaded. Please note that this tag is specifically designed for monochrome transparency channels, i.e. a transparent pen in a palette-based image. If you want to load the alphachannel of an image, set the LoadAlpha tag to True. This tag defaults to False. (V6.0)

Please note that the Transparency, LoadTransparency and LoadAlpha fields are mutually exclusive. A sprite can only have one transparency setting!

If you want to load sprites manually, please use the LoadSprite() command.

Inputs
id
a value that is used to identify this sprite later in the code
filename$
the picture file you want to load
table
optional argument specifying further options
Example
@SPRITE 1, "MySprite.png", {Transparency = #RED}
This loads "MySprite.png" as sprite 1 with the color red being transparent.


@SPRITE 1, "PlayerSprites.png", {Width = 32, Height = 32,
     Frames = 16, FPR = 8, Transparency = #BLACK}
The code above creates sprite 1 from the file "PlayerSprites.png". Sprite 1 will be of the dimensions 32x32 and will contain 16 different frames. The single frames are aligned with 8 frames per row in the image "PlayerSprites.png". Thus, @SPRITE needs to scan two rows to read the full 16 frames.

Show TOC