Sprite

┗> Object > Class

A simple object that renders a texture. \ This texture must be placed inside `assets/sprites/`.


Constructor


Sprite(texture: any, x: any, y: any, width: any, height: any, path: any)

Arguments:

texture: any
x: any
y: any
width: any
height: any
path: any




Methods


Sprite:_basicAnimation(wait: any)

Arguments:

wait: any




Sprite:crossFadeTo(texture: any, time: any, fade_out: any, after: any)

Arguments:

texture: any
time: any
fade_out: any
after: any


Sprite:crossFadeToSpeed(texture: any, speed: any, fade_out: any, after: any)

Arguments:

texture: any
speed: any
fade_out: any
after: any






Sprite:flash(offset_x: any, offset_y: any, layer: any)

Arguments:

offset_x: any
offset_y: any
layer: any

Returns:

1: FlashFade


Sprite:getPath(name: string)

(Called internally) Gets the full path to the texture this sprite should use
given a path by Sprite:setSprite(). If this sprite's path is not empty,
it will be prepended to the given path.

Arguments:

name: string

The relative path of the sprite to get the full path of.

Returns:

1: string


Sprite:getTexture()

@return texture — The current texture of the sprite, if it exists.

Returns:

texture: love.Image|nil

The current texture of the sprite, if it exists.



Sprite:hasSprite(texture: string)

@param texture — The texture to check the existence of, relative to this sprite's path.

@return exists — Whether the given texture exists.

Arguments:

texture: string

The texture to check the existence of, relative to this sprite's path.

Returns:

exists: boolean

Whether the given texture exists.



Sprite:isSprite(texture: string)

@param texture — The texture to check against this sprite's current texture, relative to this sprite's path.

@return equal — Whether the textures are equal.

Arguments:

texture: string

The texture to check against this sprite's current texture, relative to this sprite's path.

Returns:

equal: boolean

Whether the textures are equal.



Sprite:onClone(src: any)

Arguments:

src: any


Sprite:parseFrames(frames: any)

Arguments:

frames: any

Returns:

1: table|nil




Sprite:play(speed: any, loop: any, on_finished: any)

Arguments:

speed: any
loop: any
on_finished: any






Sprite:set(texture: string|table|love.Image)

Sets the sprite to either a texture or an animation.
If the given texture is a string or image, it will be passed into Sprite:setSprite().
If the given texture is a table, it will be passed into Sprite:setAnimation().

Arguments:

texture: string|table|love.Image

The texture or animation to set the sprite to.



Sprite:setAnimation(anim: any)

Arguments:

anim: any


Sprite:setCrossFadeTexture(texture: any)

Arguments:

texture: any


Sprite:setFrame(frame: number)

Sets the frame of the current sprite.
If the sprite has no frames, this will do nothing.

Arguments:

frame: number

The frame to set the sprite to. If this is outside of the range of frames, it will wrap around.



Sprite:setFrames(frames: string|table, keep_anim: boolean?)

(Called internally) Sets the current sprite to a list of frames, and updates the texture.
Note: Ignores path and single-frame textures. Use Sprite:setSprite() instead.

Arguments:

frames: string|table

The frames to set the sprite to.

keep_anim: boolean?

If true, this will not interrupt the current animation. Otherwise, any animation will be stopped.



Sprite:setProgress(progress: number)

Sets the current frame to a percentage between 0 - 1.
If progress is outside of this range, it will wrap around.

Arguments:

progress: number

The percentage (0 - 1) of the animation to set the frame to.



Sprite:setSprite(texture: string|table|love.Image, keep_anim: boolean?)

Sets the current sprite.

Arguments:

texture: string|table|love.Image

The texture to set the sprite to. If this is a string, it will be relative to this sprite's path.

keep_anim: boolean?

If true, this will not interrupt the current animation. Otherwise, any animation will be stopped.



Sprite:setTexture(texture: string|love.Image, keep_anim: boolean?)

(Called internally) Sets the current sprite to a single texture.
Note: Ignores path and frames. Use Sprite:setSprite() instead.

Arguments:

texture: string|love.Image

The texture to set the sprite to.

keep_anim: boolean?

If true, this will not interrupt the current animation. Otherwise, any animation will be stopped.



Sprite:setTextureExact(texture: any)

(Called internally) Sets the current sprite to a single texture.
Note: Only for internal overrides. Use Sprite:setSprite() instead.

Arguments:

texture: any


Sprite:setWrap(x: boolean, y: boolean?)

Sets the wrapping mode of the sprite.
The texture will repeat across the whole screen in the direction(s) specified.

Arguments:

x: boolean

Whether the texture should repeat horizontally.

y: boolean?

Whether the texture should repeat vertically. If not specified, this will be the same as x.



Sprite:stop(keep_frame: any)

Arguments:

keep_frame: any




Sprite:updateTexture()

(Called internally) Updates the sprite's texture to its current frame.
If the sprite has no frames, this will do nothing.




Fields


Sprite.anim_callback: Sprite.anim_callback|nil

A function that is called when the current animation finishes.


Sprite.anim_delay: number

(Read-only) The delay between frames in the current animation.


Sprite.anim_duration: number

(Read-only) The duration of the current animation. If greater than 0, the animation will stop after this many seconds.


Sprite.anim_frames: number[]|nil

(Read-only) A list of frame indexes the current animation loops through. If nil, the animation loops through all frames.


Sprite.anim_routine: thread|nil

(Read-only) The coroutine of the current sprite animation.


Sprite.anim_routine_func: Sprite.anim_func|nil

(Read-only) The function of the current sprite animation.


Sprite.anim_speed: number

A multiplier for how fast the sprite animates. (Defaults to 1)


Sprite.anim_sprite: string

(Read-only) The name of the sprite used in the current animation.


Sprite.anim_wait_func: Sprite.wait_func

(Read-only) The function used to wait for the next frame of the animation.


Sprite.anim_waiting: number

(Read-only) Set by the wait function of an animation routine. The amount of time left until the animation continues.


Sprite.frame: number

(Read-only) The current frame of the sprite. Set with Sprite:setFrame().


Sprite.frames: love.Image[]|nil

(Read-only) The animation frames of the sprite, or nil if the texture has no frames.


Sprite.loop: boolean

Whether the sprite will continuously loop its animation. (Defaults to false)


Sprite.path: string

The base path of the sprite.
Any calls to Sprite:setSprite() will have this path prepended to them,
only checking for textures inside this folder.
Note: This path is still relative to assets/sprites/!


Sprite.playing: boolean

(Read-only) Whether an animation is currently playing.


Sprite.texture: love.Image|nil

(Read-only) The current texture of the sprite, if it exists.


Sprite.texture_path: string|nil

(Read-only) The string ID of the current texture, if it exists.


Sprite.use_texture_size: boolean

Whether this sprite's width and height will be updated to the size of the texture.
Defaults to true if a width and height is not specified in the constructor.


Sprite.wrap_texture_x: boolean

If enabled, the texture will repeat horizontally across the screen.


Sprite.wrap_texture_y: boolean

If enabled, the texture will repeat vertically across the screen.



Undocumented