Documentation
¶
Index ¶
Constants ¶
const Delta = time.Second / 60
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnimPlayer ¶
type AnimPlayer struct {
// The frame of the animation currently being played.
//
// Example:
// dio.GeoM.Translate(animPlayer.CurrentFrame.Position.X, animPlayer.CurrentFrame.Position.Y)
// dio.GeoM.Translate(x, y)
// screen.DrawImage(g.animPlayer.CurrentFrame.Image, dio)
CurrentFrame *Frame
// The animation currently being played
CurrentAnimation *Animation
// Animations accessible by their Aseprite tag names
Animations map[string]*Animation
// If true, the animation is paused
Paused bool
// contains filtered or unexported fields
}
AnimPlayer plays and manages Aseprite tag animations.
func NewAnimPlayerFromAsepriteFile ¶
func NewAnimPlayerFromAsepriteFile(asePath string) (ap *AnimPlayer, err error)
NewAnimPlayerFromAsepriteFile creates an AnimPlayer from an Aseprite file.
The first Aseprite tag is automatically set as the current animation.
The Aseprite file must contain at least one tag, otherwise an error will occur.
func NewAnimPlayerFromAsepriteFileSystem ¶
func NewAnimPlayerFromAsepriteFileSystem(fs fs.FS, asePath string) (ap *AnimPlayer, err error)
NewAnimPlayerFromAsepriteFileSystem creates an AnimPlayer from an Aseprite file.
The first Aseprite tag is automatically set as the current animation.
The Aseprite file must contain at least one tag, otherwise an error will occur.
func (*AnimPlayer) IsEnded ¶ added in v1.4.0
func (a *AnimPlayer) IsEnded() bool
If Animation.Repeat is not zero, it returns true when the animation ends. If it is zero, it is always false.
func (*AnimPlayer) Play ¶ added in v1.4.0
func (a *AnimPlayer) Play(tag string)
Play rewinds and plays the animation.
func (*AnimPlayer) PlayIfNotCurrent ¶ added in v1.4.0
func (a *AnimPlayer) PlayIfNotCurrent(tag string)
PlayIfNotCurrent rewinds and plays the animation with the given tag if it's not already playing
func (*AnimPlayer) String ¶ added in v1.4.0
func (a *AnimPlayer) String() string
func (*AnimPlayer) Update ¶
func (a *AnimPlayer) Update(dt time.Duration)
Update advances the animation by the given delta time.
It handles frame progression, looping, and repeat count logic. Does nothing if the animation is paused or has ended.
Example:
myAnimPlayer.Update(aseplayer.Delta)
type Animation ¶
type Animation struct {
// The animation tag name is identical to the Aseprite tags
Name string
// Animation frames
Frames []Frame
// Repeat specifies how many times the animation should loop.
// A value of 0 means infinite looping.
Repeat uint16
// Text field of Aseprite Tag's User Data.
//
// It is useful for data transfer. It can be automated with Aseprite Lua scripting.
//
// https://www.aseprite.org/api/tag#tagdata
UserData string
}
Animation for AnimPlayer