Is there any way to get the time that every frame taken #870
Replies: 1 comment
-
Hi! To step animations at say, 60fps you can use the type StepAnimMsg time.Time
// Step the animation every 1/60th of a second.
func stepAnim() Cmd {
return Every(time.Second/60, func(t time.Time) Msg {
return StepAnimMsg(t)
})
}
func (m model) Init() Cmd {
// Start ticking.
return stepAnim()
}
func (m model) Update(msg Msg) (Model, Cmd) {
switch msg.(type) {
case StepAnimMsg:
now := time.Now()
delta := m.lastStep.Since(now) // here's the time delta
m.lastStep = now
return m, stepAnim() // return your Every command again to loop.
}
return m, nil
} The nice thing about If you're interested in either springs or particles the Harmonica library works great in terminals and also supports a notion of a time delta. There are also a couple of Haramonica/Bubble Tea examples that should help you wrap your head around animations in Bubble Tea in general:
Let us know if you still have questions. Side note: the default max FPS is 60. You can change it with |
Beta Was this translation helpful? Give feedback.
-
Is there any way to get the time that every frame taken? I have read the code but I cannot find anything about that. It's just like deltatime in Unity Engine or some other game engine. I want my animation played at the same speed.
Beta Was this translation helpful? Give feedback.
All reactions