Types/AnimationFrameSequence: Difference between revisions
(Added frame_sequence (0.17)) |
Stringweasel (talk | contribs) (show advanced example using multiple layers) |
||
Line 17: | Line 17: | ||
frame_count = 4, | frame_count = 4, | ||
frame_sequence = { 2, 2, 2, 2, 2, 4, 3, 4, 3 } | frame_sequence = { 2, 2, 2, 2, 2, 4, 3, 4, 3 } | ||
</syntaxhighlight> | |||
Comple example - animation contains different layers with different frame counts | |||
<syntaxhighlight lang="lua"> | |||
local custom_frame_sequence = { 2, 2, 2, 2, 2, 4, 3, 4, 3 } | |||
layers = { | |||
{ | |||
-- Animation with custom frame sequence | |||
frame_count = 4, | |||
frame_sequence = custom_frame_sequence, | |||
}, | |||
{ | |||
-- Single sprite that's repeated | |||
repeat_count = #custom_frame_sequence, | |||
}, | |||
{ | |||
-- Other animation with different frame count | |||
-- Assuming: #custom_frame_sequence < frame_count | |||
frame_count = #custom_frame_sequence, | |||
}, | |||
} | |||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 07:35, 29 October 2022
An array of Types/uint16. Used by Types/Animation and similar.
This is a list of 1-based frame indices into the spritesheet. The actual length of the animation will then be the length of the frame_sequence (times repeat_count
, times two if run_mode
is "forward-then-backward"). There is a limit for (actual) animation length of 255 frames.
Indices can be used in any order, repeated or not used at all. Unused frames are not loaded into VRAM at all, frames referenced multiple times are loaded just once.[1]
Examples
Trivial example - frame_sequence defines same sequence in which the animation would load by default, so it is useless in this case:
frame_count = 4,
frame_sequence = { 1, 2, 3, 4 }
Usage example - first five times repeat frame 2, then alternate between 4 and 3 two times. Frame 1 is not used:
frame_count = 4,
frame_sequence = { 2, 2, 2, 2, 2, 4, 3, 4, 3 }
Comple example - animation contains different layers with different frame counts
local custom_frame_sequence = { 2, 2, 2, 2, 2, 4, 3, 4, 3 }
layers = {
{
-- Animation with custom frame sequence
frame_count = 4,
frame_sequence = custom_frame_sequence,
},
{
-- Single sprite that's repeated
repeat_count = #custom_frame_sequence,
},
{
-- Other animation with different frame count
-- Assuming: #custom_frame_sequence < frame_count
frame_count = #custom_frame_sequence,
},
}