Skip to content
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

Open
6J7KZg2f opened this issue Feb 25, 2019 · 5 comments
Open

FlxTypeText counterintuitive callback behaviour #331

6J7KZg2f opened this issue Feb 25, 2019 · 5 comments

Comments

@6J7KZg2f
Copy link
Contributor

6J7KZg2f commented Feb 25, 2019

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?

@Gama11
Copy link
Member

Gama11 commented Feb 25, 2019

Actually, it seems this was a deliberate change a while ago: #293

@6J7KZg2f
Copy link
Contributor Author

Okay, in that case what about leaning towards the former of my propositions?

This code:

var myFTT = new FlxTypeText(0, 0, 0, "test");
myFTT.onComplete = function(){trace("yeah nah");};
myFTT.start();

Surely should result in yeah nah appearing in the console.

If that is incorrect usage, I don't believe onComplete should be public.

@Gama11
Copy link
Member

Gama11 commented Feb 27, 2019

@winterismute Any thoughts on this, since you made the change originally? Is this a case you considered?

@winterismute
Copy link
Contributor

winterismute commented Mar 1, 2019

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".

@migmoog
Copy link
Contributor

migmoog commented Nov 15, 2021

Can this be closed now after #353 ?

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

No branches or pull requests

4 participants