Sequence:keyframe_at
Retrieves the keyframe to play at a specific time. If the time value is greater than the sequence duration, the final keyframe will be returned.
This function will return nil if the sequence contains no keyframes.
Usage
sequence:keyframe_at(time)
Arguments
| Name | Type | Description |
|---|---|---|
time | number | Time offset in seconds. |
Returns
| Name | Type | Description |
|---|---|---|
keyframe | table | Information about the keyframe to play. |
The keyframe table contains the following members:
duration: keyframe duration in seconds.quad: a love.Quad framing the corresponding sprite in the spritesheet image.x: horizontal pixel offset to apply when displaying this frame.y: vertical pixel offset to apply when displaying this frame.
For performance reasons, this function does not return copies of the underlying data. Modifications to keyframe tables will persist across calls (and are not recommended).
Examples
local spritesheet = crystal.assets.get("assets/sprites/hero.json");
local walk = spritesheet:animation("walk");
local sequence = walk:sequence("N");
local keyframe = sequence:keyframe_at(0.1);
print(keyframe.duration);