You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue is somewhere between bug and feature request... When tween is complete, the property value is set directly to end value instead of value returned by ease function with end value as parameter. If the ease function returns f(0) = 0 and f(1) = 1, then everything works well. But, if it is not true and, for example, f(1) = 0, you will get noticable glitch.
What it is good for to return other value than 1 for f(1)? For example if you want an object to bounce in size for some reason - then the ease function can be f(v) = sin(v * PI). This function starts and ends with value equal to zero and the tween end value in fact works as amplitude. With current code it works except for the last frame - the property is not set to f(1) * endValue, but to endValue.
Another example is object(for example button) pulsing endlessly with sinewave. It works except for very last frame in each repeat - there is ugly glitch.
Found workaround and suggested solution is in part Additional Information
Example Test Code
example 1 - bounce sprite - sprite starts with scale 1, in the half of the duration its scale is 1.2, last frame before end it is close to 1 and on last frame it jumps to 1.2 (instead of 1)
It now passes the last value through ease function. Value of progress is already clamped to 0-1 range, so it should not break anything. And it also saves a few lines!
The text was updated successfully, but these errors were encountered:
Version
Description
This issue is somewhere between bug and feature request... When tween is complete, the property value is set directly to end value instead of value returned by ease function with end value as parameter. If the ease function returns f(0) = 0 and f(1) = 1, then everything works well. But, if it is not true and, for example, f(1) = 0, you will get noticable glitch.
What it is good for to return other value than 1 for f(1)? For example if you want an object to bounce in size for some reason - then the ease function can be f(v) = sin(v * PI). This function starts and ends with value equal to zero and the tween end value in fact works as amplitude. With current code it works except for the last frame - the property is not set to f(1) * endValue, but to endValue.
Another example is object(for example button) pulsing endlessly with sinewave. It works except for very last frame in each repeat - there is ugly glitch.
Found workaround and suggested solution is in part Additional Information
Example Test Code
example 1 - bounce sprite - sprite starts with scale 1, in the half of the duration its scale is 1.2, last frame before end it is close to 1 and on last frame it jumps to 1.2 (instead of 1)
example 2 - pulse sprite - the same as above. Each last frame of each repeat, the scale jumps to 1.2 (for single frame) instead of 1
Additional Information
workaround
As a workaround it is possible to overwrite object values in onRepeat/onComplete callbacks. Like this for pulsing sprite:
You have to add onRepeat if tween is repeating and onComplete if not repeating or repating is not endless.
solution
Suggested solution is an update to code in TweenData.js class in update function. Current code is this part of TweenData.js
It is possible to refactor it to this:
It now passes the last value through ease function. Value of progress is already clamped to 0-1 range, so it should not break anything. And it also saves a few lines!
The text was updated successfully, but these errors were encountered: