Exemple #1
0
func (t *Tween) updateProgress() bool {
	delta := engine.GameTime().Sub(t.startTime)
	if t.reverse {
		t.progress = 1 - float32(float64(delta)/float64(t.Time))
	} else {
		t.progress = float32(float64(delta) / float64(t.Time))
	}
	destroy := false
	t.progress, destroy = t.Loop(t, t.progress)
	return destroy
}
Exemple #2
0
func Create(t *Tween) *Tween {
	if t.To == nil || (t.To != nil && t.From == nil && t.Type == nil) {
		panic("Not possible tween")
	}
	if t.Target != nil {
		t.Target.AddComponent(newTweens(t))
	}
	if t.Algo == nil {
		t.Algo = Linear
	}
	if t.Loop == nil {
		t.Loop = None
	}
	t.startTime = engine.GameTime()
	t.progress = 0
	return t
}