Skip to content
This repository has been archived by the owner on Oct 26, 2023. It is now read-only.

[FeatureRequest] Could we have some way to know how much time passed? #1

Open
memmaker opened this issue Aug 29, 2023 · 1 comment
Open

Comments

@memmaker
Copy link

Thanks for this nice little piece of code :)

My use-case is this: I have an animation coroutine that has different stages, like it plays one animation after another. One of them is a simple simple LERPed rotation. However, that LERP function needs the delta time of the update. Is there an easy way to achieve what I want, that I just haven't figured out? If not, maybe you could add a small function like

YieldDeltaFunc(deltaFunc func(deltaTime float64) bool) error

@SolarLune
Copy link
Owner

SolarLune commented Sep 7, 2023

No problem, thanks for using it~

If I'm understanding your request, you can just use whatever delta time-measuring functions you normally have at your disposal (a global delta time variable or function, calculating 1/TPS for Ebitengine, etc). Yielding in a coroutine pauses execution for some amount of time, but that doesn't change the delta value between game frames.

QUICK EDIT: To give an example, if you have this animation coroutine, then you could use YieldFunc to create a function literal that yields execution until the animation is finished. You can call update on the animation in that literal, and pass whatever delta calculation / constant / value you normally would.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants