Skip to content

Conversation

@ninjamuffin99
Copy link
Member

…he character changes

When FlxTypeText outputs a new character, we dispatch our newly created onCharacterTyped FlxSignal.

This could also be useful in cleaning up some of that update code that runs the sounds for each character.

*/
public var eraseCallback:Void->Void;

public var onCharacterTyped(default, never):FlxSignal = new FlxSignal();
Copy link
Member

@Geokureli Geokureli Nov 4, 2025

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

Copy link
Member Author

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated with:

  • using final instead of (default, never)
  • destroy the signal with FlxDestroyUtil.destroy(onCharacterTyped) in an overridden destroy function

Comment on lines 518 to +524
onComplete();
onCharacterTyped.dispatch();
Copy link
Member

@Geokureli Geokureli Nov 4, 2025

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

Copy link
Member Author

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

@Vortex2Oblivion
Copy link
Contributor

It would be cool if it was a FlxTypedSignal so you can get the exact character typed easily

@Geokureli
Copy link
Member

I don't know if it matters but this exists

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

Successfully merging this pull request may close these issues.

3 participants