-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
Tween.setCallback bugs if optional argument (param) is not passed, also the function gets called 3 times instead of once #6047
Comments
Can you make an example for the second bug? |
I have a sprite with a repeating animation (this one) When it repeats the console logs 'test' 3 times in the same cycle each time the animation loops. Same happens if I use onYoyo. If I instead put onComplete (after removing I made sure the tween is created only once, and this is confirmed by the fact that onComplete works as intended (otherwise it could be an error on my side like creating 3 tweens that work in tandem, but it doesn't seem to be the case). I'm gonna take a look at the source code to see if I can pinpoint the problem. |
UPDATE I'm not an expert but it seems to me it's not behaving as intended, especially since it's not consistent with how onRepeat works, which gets called only once regardless of the number of values animated. |
That's the correct behavior. See TweenBuilderConfig. |
Thank you for submitting this issue. We have fixed this and the fix has been pushed to the As for the second issue, this is the correct behavior. It should fire once per property being tweened. |
Version
TL;DR
In the API Documentation here says that with Tween.setCallback the params argument is optional, but it throws an error if you don't pass anything. It works with a workaround but it gets called 3 times instead of 1.
Primary Bug
Calling this method for a tween gives an error
testAlertTween.setCallback('onYoyo', function(target){ console.log('test') });
The error gets thrown in the framework at this line (68647)
callback.params[1] = tweenData.target;
Basically it references the param's elements without checking first if it the argument have been passed
The code doesn't give error if I pass an empty array like this
testAlertTween.setCallback('onYoyo', function(target){ console.log('test') }, []);
Secondary Bug
Even though it works with this workaround, it still gets called 3 times in the same cycle instead of once with 'onYoyo' and 'on Repeat.
For more information here's the Tween:
var testAlertTween = this.tweens.add({ targets: testSprite, x: testSprite.x+400, duration: 2500, rotation: 0.3, scale: 1.5, ease: 'Linear', yoyo: true, repeat: -1, });
The text was updated successfully, but these errors were encountered: