animation

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: 1 Imported by: 0

Documentation

Overview

Package animation provides support for creating animations from sprite sheets. The sprite package uses this package to render animated sprites.

See README.md for more info.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Animation

type Animation struct {
	// contains filtered or unexported fields
}

Animation represents an animation sequence made up of 1 or more frames

func New

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

New creates an instance of an animation with frames extracted from a texture

type Animator

type Animator struct {
	// contains filtered or unexported fields
}

Animator drives an animation

func NewAnimator

func NewAnimator(name string, a *Animation) *Animator

NewAnimator creates a named animator for an animation

func (*Animator) CurrentFrame

func (p *Animator) CurrentFrame() (x, y, w, h int)

CurrentFrame returns the coordinates of the image to show for the current animation state

func (*Animator) Play

func (p *Animator) Play()

Play starts the animation playing

func (*Animator) Restart

func (p *Animator) Restart()

Restart the animation from the start frame and direction

func (*Animator) Stop

func (p *Animator) Stop()

Stop the animation

func (*Animator) Update

func (p *Animator) Update(delta float64)

Update must be called every render frame to update the animation state based on the setup of the attached animation

type Option

type Option func(a *Animation)

Option is the signature of a configuration function for an animation

func Bidi

func Bidi() Option

Bidi is an Option function make the animation run in a cycle the switches direction when it reaches either end

func Fps

func Fps(fps int) Option

Fps is an Option function that sets the frame rate that the animation will run at

func Frame

func Frame(x, y, w, h int) Option

Frame is an Option function that defines a single frame from the texture

func FrameSlicer

func FrameSlicer(offsetX, offsetY, frameWidth, frameHeight, colCount, rowCount int) Option

FrameSlicer is an Option function that slices the texture into individual frames for the animation Frames are sequenced left to right top to bottom offsetX, offsetY - starting point for slicing frames frameWidth, frameHeight - size of each frame colCount - number of horizontal frames to extract for this animation rowCount - number of vertical frames to extract for the animation

func Reverse

func Reverse() Option

Reverse is an Option function that sets the animation to run in reverse

Jump to

Keyboard shortcuts

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