The clan::Sprite resource options are a plethora of possibilities to tweak a sprites looks and behaviours, but all of them have default values. In most cases you will only need to use the basic options.
Only the name attribute of <sprite> and at least one <image> element is required to construct a sprite. The remaining elements and attributes are optional.
Using the <sprite> element
-
Attribute: name
Resource identifier to use as base for this sprite
Default value: None, MUST BE PRESENT.
-
Attribute: base_angle
Defines what direction the sprite is in. All other angles are relative to this one.
Default value: "0"
-
Attribute: id
Sets the sprite identify retrievable via clan::Sprite::get_id().
Default value: "0"
-
Element: <image>
Description of the sprite frames.
You can specify any number of <image> elements
-
Element: <color>
Description of the sprite color.
You can specify any number of <color> elements
-
Element: <frame>
Description of the sprite frames.
You can specify any number of <frame> elements
-
Element: <animation>
Description of the sprite animation.
You can specify any number of <animation> elements
-
Element: <scale>
Description of the sprite scale.
You can specify any number of <scale> elements
-
Element: <translation>
Description of the sprite translation.
You can specify any number of <translation> elements
-
Element: <rotation>
Description of the sprite rotation.
You can specify any number of <rotation> elements
Using the <image> element
The first step in setting up a sprite is telling the resource loader where it should get the images for all the frames. This is done specifying one or more <image> elements. Each <image> element specify an image from where one or several frames should be extracted:
-
If there is no child element in <image>, it will simply take the entire image and add it as one large frame.
-
If the child element is <grid> it will use the grid cutter to extract a set of frames placed in a grid in the image file.
-
If the child is <alpha> the alpha cutter will be used instead. The alpha cutter uses the alpha channel to find frames separated with pure alpha (within trans_limit).
-
Attribute: file (Optional)
Image filename.
-
Element: <grid> (Optional - Only when file attribute is set)
Use the grid cutter to extract a set of frames placed in a grid in the image file
You can specify any number of <grid> elements
-
Element: <alpha> (Optional - Only when file attribute is set)
The alpha cutter uses the alpha channel to find frames separated with pure alpha
You can specify any number of <alpha> elements
-
Attribute: fileseq (Optional)
A sequence of images.
Valid values: "filename.ext" where ext is any of the supported ClanLib image types (for example png, jpg) so that it will be translated into "filename0001.ext"
Default value: None. For non-sequenced images, use the file attribute.
-
Attribute: start_index (Optional - Used when fileseq attribute is set)
The start index.
Valid values: "integer" - greater or equal to 0
Default value: "0"
-
Attribute: skip_index (Optional - Used when fileseq attribute is set)
How many images to skip per iteration. (fileseq)
Valid values: "integer" - greater or equal to 1
Default value: "1"
-
Attribute: leading_zeroes (Optional - Used when fileseq attribute is set)
Number of zeroes before the extension.
Valid values: "integer" - greater or equal to 0
Default value: "0"
Using the <grid> element
-
Attribute: pos
Position in image to start grid-cutting.
Valid values: "integer, integer" - x-position, y-position
Default value: "0, 0"
-
Attribute: size
Size of each grid-tile.
Valid values: "integer, integer" - width, height
Default value: "1, 1"
-
Attribute: array
Grid-size.
Valid values: "integer, integer" - width, height
Default value: None, MUST BE PRESENT.
-
Attribute: array_skipframes
How many frames to skip at end of last gridline.
Valid values: "integer" - frames to skip
Default value: "0"
-
Attribute: spacing
Space between each grid-tile.
Valid values: "integer, integer" - x-spacing, y-spacing
Default value: "0, 0"
Using the <alpha> element