nori/animation.go

39 lines
703 B
Go

package nori
import (
"encoding/binary"
"io"
)
type Animation struct {
Title [32]byte
FrameCount uint32
Frames []*Frame
Version int
}
func NewAnimation(version int) *Animation {
return &Animation{Version: version}
}
func (a *Animation) Decode(rd io.Reader) error {
if err := binary.Read(rd, end, a.Title[:]); err != nil {
return err
}
if err := binary.Read(rd, end, &a.FrameCount); err != nil {
return err
}
if err := discardN(rd, 4*int(a.FrameCount)); err != nil {
return err
}
a.Frames = make([]*Frame, int(a.FrameCount))
for i := range a.Frames {
a.Frames[i] = NewFrame(a.Version)
if err := a.Frames[i].Decode(rd); err != nil {
return err
}
}
return nil
}