Types/Sprite: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
(Changed links going to the redirect Types/unsigned to go to Types/uint32.)
(0.16)
Line 3: Line 3:


When there is more than one sprite or [[Types/Animation|animation]] frame with the same source file and dimensions/position in the game, they all share the same memory.
When there is more than one sprite or [[Types/Animation|animation]] frame with the same source file and dimensions/position in the game, they all share the same memory.
== Properties ==
== Mandatory properties ==
 
=== filename ===
=== filename ===
'''Type''':[[Types/FileName]]
'''Type''': [[Types/FileName]]
=== priority ===
 
'''Type''':[[Types/string]]
'''Default''': ""


Possible values:
Technically optional, but path to sprite cannot be empty.
* extra-high
* high
* medium
* low
* very-low


=== width ===
=== width ===
'''Type''': [[Types/uint32]]
'''Type''': [[Types/SpriteSizeType]]
 
Width of the picture in pixels, from 0-8192.


Width of the picture in pixels.
=== height ===
=== height ===
'''Type''': [[Types/uint32]]
'''Type''': [[Types/SpriteSizeType]]
 
Height of the picture in pixels, from 0-8192.
 
== Optional properties ==
 
=== layers ===
'''Type''': [[Types/table]] of [[Types/Sprite]]
 
If this property is present, all Sprite definitions have to be placed as entries in the array, and they will all be loaded from there. Each item (Sprite 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.
 
=== slice ===
'''Type''': [[Types/SpriteSizeType]]
 
=== slice_x ===
'''Type''': [[Types/SpriteSizeType]]
 
=== slice_y ===
'''Type''': [[Types/SpriteSizeType]]
 
=== priority ===
'''Type''': [[Types/string]]
 
'''Default''': "medium"
 
Possible values:
* "extra-high-no-scale"
* "extra-high"
* "high"
* "medium"
* "low"
* "very-low"
 
=== flags ===
'''Type''': [[Types/SpriteFlags]]


Height of the picture in pixels
=== x ===
=== x ===
'''Type''': [[Types/uint32]]
'''Type''': [[Types/SpriteSizeType]]


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


Horizontal position of the picture in the source file in pixels.
Horizontal position of the sprite in the source file in pixels.


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


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


Vertical position of the picture in the source file in pixels.
Vertical position of the sprite in the source file in pixels.


=== shift ===
=== shift ===
Line 42: Line 74:


'''Default''': {0, 0}
'''Default''': {0, 0}
Used to offset the sprite in-game from its bounding box.


=== scale ===
=== scale ===
Line 50: Line 80:
'''Default''': 1
'''Default''': 1


Values different than 1 specify the scale of the picture on default zoom.
Values different than 1 specify the scale of the sprite 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
=== 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
=== premul_alpha ===
'''Type''': [[Types/bool]]
'''Default''': true
Whether alpha should be premultiplied.
== Example ==
== Example ==
     picture =
     picture =

Revision as of 19:04, 23 August 2018

Basics

Specifies one picture that can be used in the game.

When there is more than one sprite or animation frame with the same source file and dimensions/position in the game, they all share the same memory.

Mandatory properties

filename

Type: Types/FileName

Default: ""

Technically optional, but path to sprite cannot be empty.

width

Type: Types/SpriteSizeType

Width of the picture in pixels, from 0-8192.

height

Type: Types/SpriteSizeType

Height of the picture in pixels, from 0-8192.

Optional properties

layers

Type: Types/table of Types/Sprite

If this property is present, all Sprite definitions have to be placed as entries in the array, and they will all be loaded from there. Each item (Sprite 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.

slice

Type: Types/SpriteSizeType

slice_x

Type: Types/SpriteSizeType

slice_y

Type: Types/SpriteSizeType

priority

Type: Types/string

Default: "medium"

Possible values:

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

flags

Type: Types/SpriteFlags

x

Type: Types/SpriteSizeType

Default: 0

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

y

Type: Types/SpriteSizeType

Default: 0

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

shift

Type: Types/vector

Default: {0, 0}

scale

Type: Types/double

Default: 1

Values different than 1 specify the scale of the sprite 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

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

premul_alpha

Type: Types/bool

Default: true

Whether alpha should be premultiplied.

Example

   picture =
   {
     filename = "__base__/graphics/entity/basic-accumulator/basic-accumulator.png",
     priority = "extra-high",
     width = 124,
     height = 103,
     shift = {0.7, -0.2}
   }