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 assigns the identifier id to it.

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 the loader set using SetDefaultLoader(). 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 the adapter set using SetDefaultAdapter(). 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)

LoadPalette:
If this tag is set to True, Hollywood will load the sprite as a palette sprite. This means that you can get and modify the sprite's palette which is useful for certain effects like color cycling. You can also make pens transparent using the TransparentPen tag (see below) or the LoadTransparency tag (see above). Palette sprites also have the advantage of requiring less memory because 1 pixel just needs 1 byte of memory instead of 4 bytes for 32-bit images. This tag defaults to False. (V9.0)

TransparentPen:
If the LoadPalette tag has been set to True (see above), the TransparentPen tag can be used to define a pen that should be made transparent. Pens are counted from 0. Alternatively, you can also set the LoadTransparency tag to True to force Hollywood to use the transparent pen that is stored in the file (if the file format supports the storage of transparent pens). This tag defaults to #NOPEN. (V9.0)

UserTags:
This tag can be used to specify additional data that should be passed to loaders and adapters. If you use this tag, you must set it to a table of key-value pairs that contain the additional data that should be passed to plugins. See User tags for details. (V10.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