-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[hump.timer] Subject values are not precise to targets after timer has completed #124
Comments
You could use the https://hump.readthedocs.io/en/latest/timer.html#Timer.tween Example:
|
@usysrc This is a good workaround, but the precision issue still exists. |
there is no precision issue, the value is correct inside the after function |
There is, because of the way floating point values work. Otherwise, the example I showed in my initial post would always work, without the need for math.floor.
Actually, now that I think about it, this could cause unexpected results in some cases (such as if the subject were changed at all during the timer), so never mind. |
These are floating point numbers. It is just the way it is. But if you need the target value you can get it inside the after function.
|
I see. I guess this can't be worked around, so I'll close this issue. |
I don't know if this is the proper way to check if a timer is in progress, but I often check whether a value of a subject is set to a specific value to see whether a timer involving the subject's value is in progress. For example:
Problem is, since Lua's numbers use double-precision, sometimes
fade[1]
is not exactly equal to1
or0
after theTimer.tween
operations have completed. Therefore, in order for the above example to work properly, I would need to addmath.floor
to each instance offade[1]
:This shouldn't be needed; the final values of the subject should match those of the targets.
The text was updated successfully, but these errors were encountered: