Factorio Prototype DocsVersion 2.0.19

Sprite :: struct Example code

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.

Inherits from SpriteParameters « SpriteSource
Children

Properties

layers optional :: array[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. [...]

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. [...]

dice optional :: SpriteSizeType

Only loaded if layers is not defined. [...]

Only loaded if layers is not defined. [...]

dice_x optional :: SpriteSizeType

Only loaded if layers is not defined. [...]

Only loaded if layers is not defined. [...]

dice_y optional :: SpriteSizeType

Only loaded if layers is not defined. [...]

Only loaded if layers is not defined. [...]

Inherited from SpriteParameters
priority optional :: SpritePriority
flags optional :: SpriteFlags
shift optional :: Vector

The shift in tiles. [...]

The shift in tiles. [...]

rotate_shift optional :: bool

Whether to rotate the shift alongside the sprite's rotation. [...]

Whether to rotate the shift alongside the sprite's rotation. [...]

apply_special_effect optional :: bool
scale optional :: double

Values other than 1 specify the scale of the sprite on default zoom. [...]

Values other than 1 specify the scale of the sprite on default zoom. [...]

draw_as_shadow optional :: bool

Only one of draw_as_shadow, draw_as_glow and draw_as_light can be true. [...]

Only one of draw_as_shadow, draw_as_glow and draw_as_light can be true. [...]

draw_as_glow optional :: bool

Only one of draw_as_shadow, draw_as_glow and draw_as_light can be true. [...]

Only one of draw_as_shadow, draw_as_glow and draw_as_light can be true. [...]

draw_as_light optional :: bool

Only one of draw_as_shadow, draw_as_glow and draw_as_light can be true.

Only one of draw_as_shadow, draw_as_glow and draw_as_light can be true.

mipmap_count optional :: uint8

Only loaded if this is an icon, that is it has the flag "group=icon" or "group=gui". [...]

Only loaded if this is an icon, that is it has the flag "group=icon" or "group=gui". [...]

apply_runtime_tint optional :: bool
tint_as_overlay optional :: bool
invert_colors optional :: bool
tint optional :: Color
blend_mode optional :: BlendMode
generate_sdf optional :: bool

This property is only used by sprites used in UtilitySprites that have the "icon" flag set. [...]

This property is only used by sprites used in UtilitySprites that have the "icon" flag set. [...]

surface optional :: SpriteUsageSurfaceHint

Provides hint to sprite atlas system, so it can try to put sprites that are intended to be used at the same locations to the same sprite atlas.

Provides hint to sprite atlas system, so it can try to put sprites that are intended to be used at the same locations to the same sprite atlas.

usage optional :: SpriteUsageHint

Provides hint to sprite atlas system, so it can pack sprites that are related to each other to the same sprite atlas.

Provides hint to sprite atlas system, so it can pack sprites that are related to each other to the same sprite atlas.

Inherited from SpriteSource
filename[overridden] :: FileName

The path to the sprite file to use.

The path to the sprite file to use.

size optional :: SpriteSizeType or {SpriteSizeType, SpriteSizeType}

The width and height of the sprite. [...]

The width and height of the sprite. [...]

width optional :: SpriteSizeType

Mandatory if size is not defined. [...]

Mandatory if size is not defined. [...]

height optional :: SpriteSizeType

Mandatory if size is not defined. [...]

Mandatory if size is not defined. [...]

x optional :: SpriteSizeType

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

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

y optional :: SpriteSizeType

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

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

position optional :: {SpriteSizeType, SpriteSizeType}

Loaded only when x and y are both 0. [...]

Loaded only when x and y are both 0. [...]

load_in_minimal_mode optional :: bool

Minimal mode is entered when mod loading fails. [...]

Minimal mode is entered when mod loading fails. [...]

premul_alpha optional :: bool

Whether alpha should be pre-multiplied.

Whether alpha should be pre-multiplied.

allow_forced_downscale optional :: bool

If true, the sprite may be downsampled to half its size on load even when 'Sprite quality' graphics setting is set to 'High'. [...]

If true, the sprite may be downsampled to half its size on load even when 'Sprite quality' graphics setting is set to 'High'. [...]

Properties

layers :: array[Sprite] optional

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. layers may not be an empty table. Each definition in the array may also have the layers property.

If this property is present, all other properties, including those inherited from SpriteParameters, are ignored.

dice :: SpriteSizeType optional

Only loaded if layers is not defined.

Number of slices this is sliced into when using the "optimized atlas packing" option. If you are a modder, you can just ignore this property. Example: If this is 4, the sprite will be sliced into a 4x4 grid.

dice_x :: SpriteSizeType optional

Only loaded if layers is not defined.

Same as dice above, but this specifies only how many slices there are on the x axis.

dice_y :: SpriteSizeType optional

Only loaded if layers is not defined.

Same as dice above, but this specifies only how many slices there are on the y axis.

Overridden Properties

filename :: FileName optional

Only loaded, and mandatory if layers is not defined.

The path to the sprite file to use.

Examples

-- simple sprite
picture_set_enemy =
{
  filename = "__base__/graphics/entity/land-mine/land-mine-set-enemy.png",
  priority = "medium",
  width = 32,
  height = 32
}
-- sprite with layers
picture =
{
  layers =
  {
    {
      filename = "__base__/graphics/entity/wooden-chest/wooden-chest.png",
      priority = "extra-high",
      width = 62,
      height = 72,
      shift = util.by_pixel(0.5, -2),
      scale = 0.5
    },
    {
      filename = "__base__/graphics/entity/wooden-chest/wooden-chest-shadow.png",
      priority = "extra-high",
      width = 104,
      height = 40,
      shift = util.by_pixel(10, 6.5),
      draw_as_shadow = true,
      scale = 0.5
    }
  }
}

Type used in

Prototypes

Types

Defines