Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrAnimationExists = errors.New("animation already exists in animator instance")
ErrAnimationExists is an error returned if an Animation already exists in the animator instance.
View Source
var ErrAnimationNotFound = errors.New("animation was not found")
ErrAnimationNotFound is an error returned if an Animation called by string is not found in the animator instance.
Functions ¶
This section is empty.
Types ¶
type Animation ¶
type Animation struct { // StartFrame is the frame's starting x and y location, width and height. StartFrame image.Rectangle // FrameCount the number of frames for a particular animation. FrameCount int // speed is the speed of the animation. Speed int // Direction is the Direction the spritesheet should be read. // This should be either Horizontal or Vertical. Direction Direction // contains filtered or unexported fields }
Animation defines a spritesheet's animation.
func (*Animation) Frame ¶ added in v0.2.0
Frame returns a rect repesenting the current frame of the animation.
func (*Animation) FrameHeight ¶
FrameHeight returns the height of the frame.
func (*Animation) FrameWidth ¶
FrameWidth returns the width of the frame.
type Animations ¶ added in v0.2.0
type Animations []*Animation
Animations repesents a collection of playable animations.
type Animator ¶
type Animator interface { // Add will add an animation to the map of the animator instance. // // If an animation already exists in the map this function will // return an ErrAnimationExists error. Add(animationName string, animation *Animation) error // Play will play the animation, iterating through each frame. // // This function should be called every frame in your update function. // // If the animation name passed is not found in the animator's map an // ErrAnimationNotFound error is returned. Play(animationName string) error // Pause will stop an animation from playing until the next call to Resume. Pause() // Resume will start an animation until the next call to Pause. // // Note: you must still call the `Play()` method to iterate through the // frames of an animation. Resume() // Animation returns the currently selected animation. // // If no animation has been set using the Play() method // a zero valued Animation will be returned. Animation() *Animation // Paused returns true if the animator's current animation is paused, otherwise it returns false. Paused() bool }
Animator is an interface that acts as a handler for animations.
func NewAnimator ¶ added in v0.2.0
func NewAnimator() Animator
NewAnimator returns a new Animator interface.
Click to show internal directories.
Click to hide internal directories.