Template:Animation
Create animations from static sprite sheet images. This template aims to solve the two main disadvantages of gif:
- Semi-Tranparency (alpha channel) is not supported.
- Unable to display animation at exactly 60fps.
Usage
The values of size and frames count must be consistent with the sprite sheet image.
- First unnamed parameter
The name of the sprite sheet file to use, without extension.
- ext (optional)
The extension of the file name, without the dot. Default is ani.png;
- t (optional)
The alt text for the animation. Default is the value of first unnamed parameter;
- Second unnamed parameter
The display width of the animation, in px.
- Third unnamed parameter
The display height of the animation, without padding area (see below), in px.
- Forth unnamed parameter
Total frames count, integer.
- Fifth unnamed parameter (optional)
Interval between each frame, in ticks[1]. Default is 1.
- scale (optional)
Size scale factor, default is 1.
- block (optional)
If set, the animation will displayed in css style `display: block`. Otherwise it will use `display: inline-block`.
Example
The sprite sheet image used: File:Life Crystal (placed).ani.png
{{animation|Life Crystal (placed)|32|32|11|6}}
:
{{animation|Life Crystal (placed)|32|32|11|6|t=Life Crystal}}
:
{{animation|Life Crystal (placed)|32|32|11|6|link=Life Crystal}}
:
{{animation|Life Crystal (placed)|64|64|11|6}}
:
(2x size)
{{animation|Life Crystal (placed)|32|32|11|6|scale=2}}
:
(2x size)
{{animation|Life Crystal (placed)|32|32|11|12}}
:
(0.5x speed)
Auto mode (via database):
{{animation|Life Crystal (placed)}}
:
{{animation|Life Crystal (placed)|link=Life Crystal}}
:
{{animation|Life Crystal (placed)|64|64}}
:
(2x size)
{{animation|Life Crystal (placed)|scale=2}}
:
(2x size)
Making sprite sheet image
All frames must be the same size, and a transparent padding area (usually 2px high, to prevent "noise" when scaling) should be added below each frame (including the last frame). Then arrange them in order from top to bottom to form the sprite sheet image. tinypng.com or similer tools should be used to reduce the size of image file.
You can also add parameters for the sprite sheet image to the database.