Documentation
¶
Index ¶
- Constants
- func ColorLerp(from, to gfx.Color, f float32) gfx.Color
- func F32Lerp(from, to float32, f float32) float32
- func IntLerp(from, to int, f float32) int
- func U16Lerp(from, to uint16, f float32) uint16
- func U8Lerp(from, to uint8, f float32) uint8
- func Vec2Lerp(from, to f32.Vec2, f float32) f32.Vec2
- type AnimState
- type Animation
- type Animator
- func (am Animator) Dispose()
- func (am Animator) Forward()
- func (am Animator) OnComplete(cb EndCallback) Animator
- func (am Animator) OnUpdate(cb UpdateCallback) Animator
- func (am Animator) Reverse()
- func (am Animator) SetDuration(d float32) Animator
- func (am Animator) SetFunction(function ease.Function) Animator
- func (am Animator) SetRepeat(count int, loop LoopType) Animator
- func (am Animator) Stop()
- func (am Animator) Valid() bool
- func (am Animator) Value() (f float32)
- type Callback
- type ColorTween
- type EndCallback
- type F32Tween
- type LoopType
- type TweenEngine
- func (eng *TweenEngine) Delete(index int)
- func (eng *TweenEngine) Duration(index int) float32
- func (eng *TweenEngine) Forward(index int)
- func (eng *TweenEngine) New() (uid int)
- func (eng *TweenEngine) NewAnimator() Animator
- func (eng *TweenEngine) Reverse(index int)
- func (eng *TweenEngine) SetCompleteCallback(index int, cb EndCallback)
- func (eng *TweenEngine) SetDuration(index int, d float32)
- func (eng *TweenEngine) SetFunction(index int, fn ease.Function)
- func (eng *TweenEngine) SetRepeat(index int, count int, loop LoopType)
- func (eng *TweenEngine) SetTimeScale(sk float32)
- func (eng *TweenEngine) SetUpdateCallback(index int, cb UpdateCallback)
- func (eng *TweenEngine) Stop(index int)
- func (eng *TweenEngine) Update(dt float32)
- func (eng *TweenEngine) Value(index int) (f float32)
- type UpdateCallback
- type Value
- type Vec2Tween
Constants ¶
const ( RepeatOnce = 1 RepeatInfinite = -1 )
Sets how many times the animation should be repeated.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Animation ¶
type Animation struct { LoopType // contains filtered or unexported fields }
维护动画的状态数据 底层动画系统,使用float作为单位 0-1
type Animator ¶
type Animator struct {
// contains filtered or unexported fields
}
func (Animator) OnComplete ¶
func (am Animator) OnComplete(cb EndCallback) Animator
func (Animator) OnUpdate ¶
func (am Animator) OnUpdate(cb UpdateCallback) Animator
func (Animator) SetDuration ¶
type Callback ¶
type Callback struct { UpdateCallback EndCallback }
type ColorTween ¶
type ColorTween struct {
// contains filtered or unexported fields
}
A gfx.Color linear interpolation between a beginning and ending value. It use the Animator as the input.
func (*ColorTween) Animate ¶
func (t *ColorTween) Animate(animator Animator) Animator
Animate sets the Animator that drives the Tween.
func (*ColorTween) Animator ¶
func (t *ColorTween) Animator() Animator
Animator returns the Animator driving the Tween.
func (*ColorTween) Range ¶
func (t *ColorTween) Range(from, to gfx.Color) *ColorTween
Range sets the beginning and ending value of the ColorTween.
func (*ColorTween) Value ¶
func (t *ColorTween) Value() gfx.Color
Returns the interpolated value for the current value of the given Animator.
type EndCallback ¶
type EndCallback func(reverse bool)
type F32Tween ¶
type F32Tween struct {
// contains filtered or unexported fields
}
A float32 linear interpolation between a beginning and ending value. It use the Animator as the input.
type TweenEngine ¶
type TweenEngine struct {
// contains filtered or unexported fields
}
func NewEngine ¶
func NewEngine() *TweenEngine
func (*TweenEngine) Delete ¶
func (eng *TweenEngine) Delete(index int)
func (*TweenEngine) Duration ¶
func (eng *TweenEngine) Duration(index int) float32
func (*TweenEngine) Forward ¶
func (eng *TweenEngine) Forward(index int)
Play an animation, produces values that range from 0.0 to 1.0, during a given duration.
func (*TweenEngine) New ¶
func (eng *TweenEngine) New() (uid int)
func (*TweenEngine) NewAnimator ¶
func (eng *TweenEngine) NewAnimator() Animator
func (*TweenEngine) Reverse ¶
func (eng *TweenEngine) Reverse(index int)
Play an animation in reverse. If the animation is already running, stop itself and play backwards from the point. If the animation is not running, then it will start from the end and play backwards.
func (*TweenEngine) SetCompleteCallback ¶
func (eng *TweenEngine) SetCompleteCallback(index int, cb EndCallback)
func (*TweenEngine) SetDuration ¶
func (eng *TweenEngine) SetDuration(index int, d float32)
Duration is the length of time this animation should last.
func (*TweenEngine) SetFunction ¶
func (eng *TweenEngine) SetFunction(index int, fn ease.Function)
func (*TweenEngine) SetRepeat ¶
func (eng *TweenEngine) SetRepeat(index int, count int, loop LoopType)
Repeat the animation. If playback type is forward, restart the animation from start, if the playback type is backward or ping-pong,
func (*TweenEngine) SetTimeScale ¶
func (eng *TweenEngine) SetTimeScale(sk float32)
func (*TweenEngine) SetUpdateCallback ¶
func (eng *TweenEngine) SetUpdateCallback(index int, cb UpdateCallback)
func (*TweenEngine) Update ¶
func (eng *TweenEngine) Update(dt float32)
It's not easy to maintain the callback, one many add or delete animation while looping. Thanks to our delayed deleting strategy that delete operation only mark the animation 'Disposed' and will not change the size of the active animation. But add new animation will change the size, since new animation is always appended to the end. We can easily know the real size. Note: we need a BETTER callback policy.
func (*TweenEngine) Value ¶
func (eng *TweenEngine) Value(index int) (f float32)
type UpdateCallback ¶
type Vec2Tween ¶
type Vec2Tween struct {
// contains filtered or unexported fields
}
A f32.Vec2 linear interpolation between a beginning and ending value. It use the Animator as the input.