Documentation ¶
Overview ¶
Package anim implements animations. It's a modified version of https://github.com/yohamta/ganim8 .
Index ¶
- Constants
- Variables
- func Nop(anim *Animation, loops int)
- func Pause(anim *Animation, loops int)
- func PauseAtEnd(anim *Animation, loops int)
- func PauseAtStart(anim *Animation, loops int)
- type AnimController
- type Animation
- func (anim *Animation) Clone() *Animation
- func (anim *Animation) Draw(screen *ebiten.Image, pt image.Point)
- func (anim *Animation) Durations() []time.Duration
- func (anim *Animation) GoToFrame(position int)
- func (anim *Animation) IsEnd() bool
- func (anim *Animation) Pause()
- func (anim *Animation) PauseAtEnd()
- func (anim *Animation) PauseAtStart()
- func (anim *Animation) Position() int
- func (anim *Animation) Resume()
- func (anim *Animation) SetDurations(durations interface{})
- func (anim *Animation) SetOnLoop(onLoop OnLoop)
- func (anim *Animation) Status() Status
- func (anim *Animation) Timer() time.Duration
- func (anim *Animation) TotalDuration() time.Duration
- func (anim *Animation) Update()
- func (anim *Animation) UpdateWithDelta(elapsedTime time.Duration)
- type OnLoop
- type Status
Constants ¶
const ( Playing = iota Paused )
const Dur24FPS time.Duration = 41 * time.Millisecond
Variables ¶
var DefaultDelta = time.Millisecond * 16
Functions ¶
func PauseAtEnd ¶
PauseAtEnd pauses the animation and set the position to the last frame.
func PauseAtStart ¶
PauseAtStart pauses the animation and set the position to the first frame.
Types ¶
type AnimController ¶
type AnimController struct {
// contains filtered or unexported fields
}
func NewAnimController ¶
func NewAnimController() *AnimController
func (*AnimController) Draw ¶
func (ac *AnimController) Draw(img *ebiten.Image, pt image.Point)
func (*AnimController) GetAnim ¶
func (ac *AnimController) GetAnim(name string) *Animation
func (*AnimController) Play ¶
func (ac *AnimController) Play(name string)
func (*AnimController) SetAnim ¶
func (ac *AnimController) SetAnim(name string, anim *Animation)
func (*AnimController) Update ¶
func (ac *AnimController) Update()
type Animation ¶
type Animation struct {
// contains filtered or unexported fields
}
Animation represents an animation created from specified frames and an *ebiten.Image
func NewAnimation ¶
NewAnimation returns a new animation object
durations is a time.Duration or a []time.Duration or a map[string]time.Duration. When it's a time.Duration, it represents the duration of all frames in the animation. When it's a []time.Duration, it can represent different durations for different frames. You can specify durations for all frames individually, like this: []time.Duration { 100 * time.Millisecond, 100 * time.Millisecond } or you can specify durations for ranges of frames: map[string]time.Duration { "1-2": 100 * time.Millisecond, "3-5": 200 * time.Millisecond }.
func (*Animation) GoToFrame ¶
GoToFrame sets the position of the animation and sets the timer at the start of the frame.
func (*Animation) PauseAtEnd ¶
func (anim *Animation) PauseAtEnd()
PauseAtEnd pauses the animation and set the position to the last frame.
func (*Animation) PauseAtStart ¶
func (anim *Animation) PauseAtStart()
PauseAtStart pauses the animation and set the position to the first frame.
func (*Animation) Position ¶
Position returns the current position of the frame. The position counts from 1 (not 0).
func (*Animation) SetDurations ¶
func (anim *Animation) SetDurations(durations interface{})
SetDurations sets the durations of the animation.
func (*Animation) TotalDuration ¶
TotalDuration returns the total duration of the animation.
func (*Animation) UpdateWithDelta ¶
UpdateWithDelta updates the animation with the specified delta.
type OnLoop ¶
OnLoop is callback function which representing one of the animation methods. it will be called every time an animation "loops".
It will have two parameters: the animation instance, and how many loops have been elapsed.
The value would be Nop (No operation) if there's nothing to do except for looping the animation.
The most usual value (apart from none) is the string 'pauseAtEnd'. It will make the animation loop once and then pause and stop on the last frame.