sprite

package
v0.0.0-...-624b60e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package sprite adds some basic sprite support to the gfx package.

See README.md for more info.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(s *Sprite)

Option is the signature of a configuration function for a Sprite

func Animation

func Animation(name string, a *animation.Animation) Option

Animation is an Option function that adds a named animation to the sprite

func Origin

func Origin(x, y int) Option

Origin is an Option function that sets the sprites origin

type Sprite

type Sprite struct {
	X, Y float64
	// contains filtered or unexported fields
}

Sprite represents a sprite

func New

func New(t *gfx.Texture, opts ...Option) *Sprite

New creates a new sprite. If there are no animations the entire texture is used to render the sprite

func (*Sprite) PlayAnimation

func (s *Sprite) PlayAnimation(name string, restart bool)

PlayAnimation selects the animation to play for the sprite

func (*Sprite) ResetAnimation

func (s *Sprite) ResetAnimation()

ResetAnimation resets the animation to the first frame

func (*Sprite) StopAnimation

func (s *Sprite) StopAnimation()

StopAnimation stops the sprites animation

func (*Sprite) Update

func (s *Sprite) Update(delta float64)

Update will updates the sprite, including the currently active animation

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL