Template:Animation/doc

From Terraria Wiki
Jump to navigation Jump to search

Create animations from static sprite sheet images. This template aims to solve the two main disadvantages of gif:

  1. Semi-Tranparency (alpha channel) is not supported.
  2. 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}}: Life Crystal (placed)

{{animation|Life Crystal (placed)|32|32|11|6|t=Life Crystal}}: Life Crystal

{{animation|Life Crystal (placed)|32|32|11|6|link=Life Crystal}}: Life Crystal (placed)

{{animation|Life Crystal (placed)|64|64|11|6}}: Life Crystal (placed) (2x size)

{{animation|Life Crystal (placed)|32|32|11|6|scale=2}}: Life Crystal (placed) (2x size)

{{animation|Life Crystal (placed)|32|32|11|12}}: Life Crystal (placed) (0.5x speed)

Auto mode (via database):

{{animation|Life Crystal (placed)}}: Life Crystal (placed)

{{animation|Life Crystal (placed)|link=Life Crystal}}: Life Crystal (placed)

{{animation|Life Crystal (placed)|64|64}}: Life Crystal (placed) (2x size)

{{animation|Life Crystal (placed)|scale=2}}: Life Crystal (placed) (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.

See also

Footnotes

  1. A tick is a time unit countable by the software. Most of Terraria's updating logic happens every tick. A tick has the length of 1/60th of a second, hence there are 60 ticks in a second and 3600 ticks in a minute.