Aseprite animation player for Ebitengine.
There are two methods available to read Aseprite files.
animPlayer := aseplayer.NewAnimPlayerFromAsepriteFile("player.ase")
animPlayer := aseplayer.NewAnimPlayerFromAsepriteFileSystem(fsys, "player.ase")Note
Layers are flattened, blending modes are applied, and frames are arranged on a single texture atlas. Invisible and reference layers are ignored.
Each Aseprite Tag is imported as an Animation{} struct and is ready to play. Each Tag's frames are stored as a []*ebiten.Image.
AsePlayer supports three Animation Directions: Forward, Reverse, and Ping-pong.
Note
For Ping-Pong and Reverse playback, the Frames []*ebiten.Image slice is specifically manipulated. For Ping-Pong, the number of frames will be greater than the Aseprite range. [0 1 2 3] -> [0 1 2 3 2 1]. Reverse is an reversed []*ebiten.Image.
AsePlayer supports the Repeat property; Animation.Repeat = 0 means infinite loop.
// Override.
g.animPlayer.Animations["turn"].Repeat = 1Frame durations are supported. The animation plays according to these durations.
// Override the third "walk" frame's duration.
animPlayer.Animations["walk"].Durations[2] = time.Millisecond * 100A pseudo-code for basic usage with Play()
func (g *Game) Update() error {
if inpututil.IsKeyJustPressed(ebiten.KeyRight) {
g.AnimPlayer.Play("walk")
}
if inpututil.IsKeyJustPressed(ebiten.KeySpace) {
g.AnimPlayer.Play("jump")
}
// Update AnimPlayer
g.myAnimPlayer.Update(aseplayer.Delta)
return nil
}
func (g *Game) Draw(s *ebiten.Image) {
// Draw AnimPlayer
s.DrawImage(g.myAnimPlayer.CurrentFrame, nil)
}