Documentation ¶
Index ¶
- Constants
- type AnimFile
- type Animation
- func (a *Animation) AddAnim(idx string, pic pixel.Picture, yOffset, width, height float64, ...)
- func (a *Animation) CurrentAnim() string
- func (a *Animation) CurrentFrameNumber() int
- func (a *Animation) Draw(target pixel.Target, dt float64)
- func (a *Animation) IsOver() bool
- func (a *Animation) SetCurrentAnim(ID string) error
Constants ¶
const ( ErrorVersionNotSupported = "Version \"%s\" not supported" ErrorNoAnims = "File must have at least one animation declared, none found" )
Returned errors
const ( SingleReverse = iota - 2 CircularReverse Circular Single )
Animation types of cycles
const (
ErrorAnimationDoesNotExist = "Animation '%s' does not exist"
)
Returned errors
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnimFile ¶
type AnimFile struct { Version string Sheet string Anims map[string]struct { Frames int Cycle string Duration float64 YOffset float64 `json:"y_offset"` Width float64 Height float64 } }
AnimFile defines the structure of a disk file containing information about animations
type Animation ¶
Animation implements an animated sprite
func NewAnimation ¶
NewAnimation returns a new Sprite instance to be drawn at position x, y
func (*Animation) AddAnim ¶
func (a *Animation) AddAnim(idx string, pic pixel.Picture, yOffset, width, height float64, numberFrames int, duration float64, cycle string)
AddAnim adds a new animation to the Sprite, identified with ID, whose frames are taken from pic from left to right, starting from X = 0 duration defines how many seconds should it take for the animation to complete a cycle
func (*Animation) CurrentAnim ¶
CurrentAnim returns the current animation index
func (*Animation) CurrentFrameNumber ¶
CurrentFrameNumber returns the frame number that it is drawn
func (*Animation) Draw ¶
Draw draws Sprite current frame on target, and updates the former if needed
func (*Animation) SetCurrentAnim ¶
SetCurrentAnim defines which animation to play