Class Sprite

Sprite class is a helper object for drawing textures that can contain a set of frames and play animations.

Functions

sprite:init (quads, image) The public constructor.
sprite:clone () Clone (shallow copy).
sprite:get_frame_viewport () Get current frame viewport.
sprite:get_frame_index () Get index of current frame.
sprite:set_frame_index (index) Set frame by index.
sprite:set_pivot (px, py) Set sprite pivot.
sprite:get_frame_count () Get frame count.
sprite:get_frame_uv (i) Get normalized frame texture UV coordinates [0 - 1]
sprite:reset (duration) Reset animation.
sprite:update (dt) Sprite animation update function.
sprite:draw (x, y, angle, sx, sy, ox, oy, kx, ky) Sprite draw function.
sprite:draw_ex (x, y, fit, bound_w, bound_h, onx, ony, angle, kx, ky, sx, sy) Sprite draw_ex function.


Functions

sprite:init (quads, image)
The public constructor.

Parameters:

sprite:clone ()
Clone (shallow copy).

Returns:

    Sprite object
sprite:get_frame_viewport ()
Get current frame viewport.

Returns:

  1. number x
  2. number y
  3. number w
  4. number h
sprite:get_frame_index ()
Get index of current frame.

Returns:

    number index
sprite:set_frame_index (index)
Set frame by index.

Parameters:

  • index number frame index
sprite:set_pivot (px, py)
Set sprite pivot.

Parameters:

  • px number
  • py number
sprite:get_frame_count ()
Get frame count.

Returns:

    number
sprite:get_frame_uv (i)
Get normalized frame texture UV coordinates [0 - 1]

Parameters:

  • i number frame index

Returns:

    table {x1=, y1=, x2=, y2=}
sprite:reset (duration)
Reset animation.

Parameters:

  • duration number

Returns:

    self
sprite:update (dt)
Sprite animation update function.

Parameters:

  • dt number
sprite:draw (x, y, angle, sx, sy, ox, oy, kx, ky)
Sprite draw function. See love.graphics.draw.

Parameters:

  • x number
  • y number
  • angle number
  • sx number
  • sy number
  • ox number
  • oy number
  • kx number
  • ky number
sprite:draw_ex (x, y, fit, bound_w, bound_h, onx, ony, angle, kx, ky, sx, sy)
Sprite draw_ex function.

Parameters:

  • x number
  • y number
  • fit string Must be 'max' or 'min'
  • bound_w number Width of bounding volume
  • bound_h number Height of bounding volume
  • onx number
  • ony number
  • angle number
  • kx number
  • ky number
  • sx number
  • sy number
generated by LDoc 1.4.6 Last updated 2023-03-21 17:41:24