-
Notifications
You must be signed in to change notification settings - Fork 142
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
FlxTypeText counterintuitive callback behaviour #331
Comments
Actually, it seems this was a deliberate change a while ago: #293 |
Okay, in that case what about leaning towards the former of my propositions? This code:
Surely should result in If that is incorrect usage, I don't believe onComplete should be public. |
@winterismute Any thoughts on this, since you made the change originally? Is this a case you considered? |
The fact is that, depending on the mental model of the person that wants to use the class FlxTypeText, both using null to "force the callback to null" or not to do it might appear as sensible options for the behaviour of "start". I think at this point the best thing would be to remove the parameter from "start" and just have people set it explicitly if they want to use it, so that this does not interfere with the call to "start". A callback parameter could be potentially added to the constructor if we think a common usage of the object might be "attach a callback that you want to have called every time you restart". |
Can this be closed now after #353 ? |
Currently FlxTypeText.onComplete:Void->Void is public, and "Callback" is an optional paramater of FlxTypeText.start().
However, leaving out the Callback paramater of start() causes onComplete to be overwritten with null, meaning the only time you could meaningfully set onComplete directly is after calling start() but before the animation completes.
We could check for null in start(), but that would prevent you from intentionally nulling the callback when calling start.
I propose either making onComplete private, or removing Callback from start().
I personally lean towards the latter, as it creates less-messy function calls.
Thoughts?
The text was updated successfully, but these errors were encountered: