Types/Animation: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
(9 intermediate revisions by 2 users not shown)
Line 3: Line 3:


Note that if any frame of the animation is specified from the same source as any other [[Types/Sprite]] or frame of other animation, it will be shared.
Note that if any frame of the animation is specified from the same source as any other [[Types/Sprite]] or frame of other animation, it will be shared.
== Mandatory properties ==
=== frame_count ===
'''Type''': [[Types/uint32]]
Can't be 0.
== Optional properties ==
=== layers ===
'''Type''': [[Types/table]] of [[Types/Animation]]
If this property is present, all Animation definitions have to be placed as entries in the array, and they will all be loaded from there. Each item (Animation definition) in the array may also have the <code>layers</code> property.
If this property is present, all other properties are ignored and the mandatory properties do not have to be defined.
=== hr_version ===
'''Type''': [[Types/Animation]]
If this property exists and high resolution sprites are turned on, its contents are used to load the Animation.


Can be nil.
== Properties ==
=== filename ===
=== filename ===
'''Type''':[[Types/FileName]]
'''Type''': [[Types/FileName]]
=== stripes ===
 
'''Type''': [[Types/Stripes]]
'''Default''': ""
 
Mandatory if <code>"stripes"</code> is not specified.


Alternative picture specification to filename, it can specify more files to be used and composed as the input.
=== priority ===
=== priority ===
'''Type''':[[Types/string]]
'''Type''': [[Types/string]]
 
'''Default''': "medium"


Possible values:
Possible values:
* extra-high
* "extra-high-no-scale"
* high
* "extra-high"
* medium
* "high"
* low
* "medium"
* very-low
* "low"
* "very-low"
 
=== flags ===
'''Type''': [[Types/SpriteFlags]]


=== width ===
=== size ===
'''Type''': [[Types/uint]]
'''Type''': [[Types/SpriteSizeType]] or [[Types/table]] of [[Types/SpriteSizeType]]


Width of one frame in pixels.
The width and height of the one frame. If this is an array, the first member of the array is the width and the second is the height. Otherwise the size is both width and height.


pre v0.11 '''frame_width''' was used.
Width and height may only be in the range of 0-8192.
=== height ===
'''Type''': [[Types/uint]]


Height of one frame in pixels.
=== width ===
'''Type''': [[Types/SpriteSizeType]]


pre v0.11 '''frame_height''' was used.
Mandatory if <code>size</code> is not given. Width of one frame in pixels, from 0-8192.
=== frame_count ===
'''Type''': [[Types/uint]]
=== line_length ===
'''Type''': [[Types/uint]]


Once the specified number of pictures is loaded, other pictures are loaded on other line.
=== height ===
This is to allow having longer animations in matrix, to avoid pictures with too big width.
'''Type''': [[Types/SpriteSizeType]]
The game engine limits the width of any input picture to 2048px, so it is compatible with most graphics cards.
=== run_mode ===
'''Type''': [[Types/string]]


Possible values are:
Mandatory if <code>size</code> is not given. Height of one frame in pixels, from 0-8192.
*forward
*backward
*forward-then-backward
=== animation_speed ===
'''Type''': [[Types/float]]


Modifier of the animation playing speed, the default is 1, which means one animation frame per tick (60 fps).
The speed of playing can often vary depending on the usage (output of steam engine for example). Can't be 0.
=== x ===
=== x ===
'''Type''': [[Types/uint]]
'''Type''': [[Types/SpriteSizeType]]


'''Default''': 0
'''Default''': 0
Line 62: Line 72:


=== y ===
=== y ===
'''Type''': [[Types/uint]]
'''Type''': [[Types/SpriteSizeType]]


'''Default''': 0
'''Default''': 0


Vertical position of the animation in the source file in pixels.
Vertical position of the animation in the source file in pixels.
=== position ===
'''Type''': [[Types/table]] of [[Types/SpriteSizeType]]
Loaded only when <code>x</code> and <code>y</code> are both 0. The first member of the array is x and the second is y.


=== shift ===
=== shift ===
'''Type''': [[Types/vector]]
'''Type''': [[Types/vector]]


'''Default''': 0
'''Default''': {0, 0}
 
=== scale ===
=== scale ===
'''Type''': [[Types/double]]
'''Type''': [[Types/double]]
Line 79: Line 95:
Values different than 1 specify the scale of the animation on default zoom.
Values different than 1 specify the scale of the animation on default zoom.
Scale 2 means that the picture will be 2 times bigger on screen (and more pixelated).
Scale 2 means that the picture will be 2 times bigger on screen (and more pixelated).
=== draw_as_shadow ===
'''Type''': [[Types/bool]]
'''Default''': false
=== mipmap_count ===
'''Type''': [[Types/uint8]]
'''Default''': 0
Only loaded if this is an icon (has flag "icon").
=== apply_runtime_tint ===
'''Type''': [[Types/bool]]
'''Default''': false
=== tint ===
'''Type''': [[Types/Color]]
'''Default''': {r=1, g=1, b=1, a=1} (white)
=== blend_mode ===
'''Type''': [[Types/string]]
'''Default''': "normal"
Possible values:
* "normal"
* "additive"
* "additive-soft"
* "multiplicative"
* "overwrite"
=== load_in_minimal_mode ===
'''Type''': [[Types/bool]]
'''Default''': false
Minimal mode is entered when mod loading fails. You are in it when you see the gray box after (part of) the loading screen that tells you a mod error ([https://cdn.discordapp.com/attachments/340530709712076801/532315796626472972/unknown.png Example]). If you are a modder, you can just ignore this property.
=== premul_alpha ===
'''Type''': [[Types/bool]]
'''Default''': true
Whether alpha should be premultiplied.
=== generate_sdf ===
'''Type''': [[Types/bool]]
'''Default''': false
=== run_mode ===
'''Type''': [[Types/string]]
'''Default''': "forward"
Possible values are:
*forward
*backward
*forward-then-backward
=== line_length ===
'''Type''': [[Types/uint32]]
'''Default''': 0
Once the specified number of pictures is loaded, other pictures are loaded on other line.
This is to allow having longer animations in matrix, to avoid pictures with too big width.
The game engine limits the width of any input picture to 2048px, so it is compatible with most graphics cards.
=== animation_speed ===
'''Type''': [[Types/float]]
'''Default''': 1
Modifier of the animation playing speed, the default is 1, which means one animation frame per tick (60 fps).
The speed of playing can often vary depending on the usage (output of steam engine for example). Can't be 0.
=== max_advance ===
'''Type''': [[Types/float]]
'''Default''': MAX_FLOAT
=== repeat_count ===
'''Type''': [[Types/uint8]]
'''Default''': 1
Can't be 0.
=== stripes ===
'''Type''': [[Types/table|table]] of [[Types/Stripe|Stripe]]


== Example ==
== Example ==
Specification of animation of electric furnace
Specification of animation of a beacon
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
    on_animation =
animation =
    {
{
      filename = "__base__/graphics/entity/electric-furnace/electric-furnace.png",
  filename = "__base__/graphics/entity/beacon/beacon-antenna.png",
      priority = "high",
  width = 54,
      x = 131,
  height = 50,
      frame_width = 131,
  line_length = 8,
      frame_height = 102,
  frame_count = 32,
      frame_count = 12,
  shift = { -0.03125, -1.71875},
      animation_speed = 0.5, --0.5 frames per tick, so 2 ticks per animation frame, so 30 frames per second
  animation_speed = 0.5
      shift = {0.5, 0.05 }
},</syntaxhighlight>
    },</syntaxhighlight>
 
{{Prototype property type usage|{{FULLPAGENAME}}?Animation]}}

Revision as of 17:03, 8 August 2019

Basics

Specifies animation that can be used in the game.

Note that if any frame of the animation is specified from the same source as any other Types/Sprite or frame of other animation, it will be shared.

Mandatory properties

frame_count

Type: Types/uint32

Can't be 0.

Optional properties

layers

Type: Types/table of Types/Animation

If this property is present, all Animation definitions have to be placed as entries in the array, and they will all be loaded from there. Each item (Animation definition) in the array may also have the layers property.

If this property is present, all other properties are ignored and the mandatory properties do not have to be defined.

hr_version

Type: Types/Animation

If this property exists and high resolution sprites are turned on, its contents are used to load the Animation.

filename

Type: Types/FileName

Default: ""

Mandatory if "stripes" is not specified.

priority

Type: Types/string

Default: "medium"

Possible values:

  • "extra-high-no-scale"
  • "extra-high"
  • "high"
  • "medium"
  • "low"
  • "very-low"

flags

Type: Types/SpriteFlags

size

Type: Types/SpriteSizeType or Types/table of Types/SpriteSizeType

The width and height of the one frame. If this is an array, the first member of the array is the width and the second is the height. Otherwise the size is both width and height.

Width and height may only be in the range of 0-8192.

width

Type: Types/SpriteSizeType

Mandatory if size is not given. Width of one frame in pixels, from 0-8192.

height

Type: Types/SpriteSizeType

Mandatory if size is not given. Height of one frame in pixels, from 0-8192.

x

Type: Types/SpriteSizeType

Default: 0

Horizontal position of the animation in the source file in pixels.

y

Type: Types/SpriteSizeType

Default: 0

Vertical position of the animation in the source file in pixels.

position

Type: Types/table of Types/SpriteSizeType

Loaded only when x and y are both 0. The first member of the array is x and the second is y.

shift

Type: Types/vector

Default: {0, 0}

scale

Type: Types/double

Default: 1

Values different than 1 specify the scale of the animation on default zoom. Scale 2 means that the picture will be 2 times bigger on screen (and more pixelated).

draw_as_shadow

Type: Types/bool

Default: false

mipmap_count

Type: Types/uint8

Default: 0

Only loaded if this is an icon (has flag "icon").

apply_runtime_tint

Type: Types/bool

Default: false

tint

Type: Types/Color

Default: {r=1, g=1, b=1, a=1} (white)

blend_mode

Type: Types/string

Default: "normal"

Possible values:

  • "normal"
  • "additive"
  • "additive-soft"
  • "multiplicative"
  • "overwrite"

load_in_minimal_mode

Type: Types/bool

Default: false

Minimal mode is entered when mod loading fails. You are in it when you see the gray box after (part of) the loading screen that tells you a mod error (Example). If you are a modder, you can just ignore this property.

premul_alpha

Type: Types/bool

Default: true

Whether alpha should be premultiplied.

generate_sdf

Type: Types/bool

Default: false

run_mode

Type: Types/string

Default: "forward"

Possible values are:

  • forward
  • backward
  • forward-then-backward

line_length

Type: Types/uint32

Default: 0

Once the specified number of pictures is loaded, other pictures are loaded on other line. This is to allow having longer animations in matrix, to avoid pictures with too big width. The game engine limits the width of any input picture to 2048px, so it is compatible with most graphics cards.

animation_speed

Type: Types/float

Default: 1

Modifier of the animation playing speed, the default is 1, which means one animation frame per tick (60 fps). The speed of playing can often vary depending on the usage (output of steam engine for example). Can't be 0.

max_advance

Type: Types/float

Default: MAX_FLOAT

repeat_count

Type: Types/uint8

Default: 1

Can't be 0.

stripes

Type: table of Stripe

Example

Specification of animation of a beacon

animation =
{
  filename = "__base__/graphics/entity/beacon/beacon-antenna.png",
  width = 54,
  height = 50,
  line_length = 8,
  frame_count = 32,
  shift = { -0.03125, -1.71875},
  animation_speed = 0.5
},

Prototype properties that use this type