gfx.sprite.sprite

gfx.sprite

sprite(src, opts) -> sprite, err

Create a sprite viewing a region of a canvas/surface/sprite

opts.sx, opts.sy set the top-left, default 1, 1. opts.sw, opts.sh set the size, default the whole source. The rect counts on the surface, whatever the source: a sprite of a sprite does not offset by its parent's rect. The sprite shares the source's pixels; it is a view, not a copy. Returns nil and an error for a source that is not a canvas, surface or sprite.