-
Notifications
You must be signed in to change notification settings - Fork 157
add onCharacterTyped signal in FlxTypeText which will dispatch when t… #468
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
base: dev
Are you sure you want to change the base?
add onCharacterTyped signal in FlxTypeText which will dispatch when t… #468
Conversation
…he character changes
flixel/addons/text/FlxTypeText.hx
Outdated
| */ | ||
| public var eraseCallback:Void->Void; | ||
|
|
||
| public var onCharacterTyped(default, never):FlxSignal = new FlxSignal(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on this:
public final onTextAdded = new FlxTypedSignal<String>();TBH, I didn't know (default, never) was valid code, final is more typical of things defined once at construction.
I also assume that the type rate can be fast enough that multiple chars can be typed in a single frame, not sure though. but sending the chars will allow people to use custom sounds or logic depending on the character
Lastly, destroy should clear all listeners
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah good catch, i think the (default, never) bit is just a random habit i have, using final make sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated with:
- using
finalinstead of(default, never) - destroy the signal with
FlxDestroyUtil.destroy(onCharacterTyped)in an overridden destroy function
| onComplete(); | ||
| onCharacterTyped.dispatch(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems odd to dispatch this after onComplete. I also wonder if rather than calling it in two places can we just dispatch it once, immediately after the text is changed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that doesn't account for the cursorCharacter, so when the cursor blinks, it will incorrectly dispatch the signal. This signal is meant a bit specifically for when a character is actually added/changed in the FlxTypeText. I think right now FlxTypeText can be cleaned up a bit in general, where these 2 dispatches can become 1 more simply along with other little tidyings
… when the character changes
|
It would be cool if it was a FlxTypedSignal so you can get the exact character typed easily |
|
I don't know if it matters but this exists |
…he character changes
When FlxTypeText outputs a new character, we dispatch our newly created
onCharacterTypedFlxSignal.This could also be useful in cleaning up some of that update code that runs the sounds for each character.