Package com.github.tommyettinger.textra
Class TypingAdapter
java.lang.Object
com.github.tommyettinger.textra.TypingAdapter
- All Implemented Interfaces:
TypingListener
Simple listener for label events. You can derive from this and only override what you are interested in.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
end()
Called when the char progression reaches the end.void
Called each time anEVENT
token is processed.void
onChar
(long ch) Called when a new character is displayed.replaceVariable
(String variable) Called when variable tokens are replaced in text.
-
Constructor Details
-
TypingAdapter
public TypingAdapter()
-
-
Method Details
-
event
Description copied from interface:TypingListener
Called each time anEVENT
token is processed.- Specified by:
event
in interfaceTypingListener
- Parameters:
event
- Name of the event specified in the token. e.g.{EVENT=player_name}
will haveplayer_name
as argument.
-
end
public void end()Description copied from interface:TypingListener
Called when the char progression reaches the end.- Specified by:
end
in interfaceTypingListener
-
replaceVariable
Description copied from interface:TypingListener
Called when variable tokens are replaced in text. This is an alternative method to deal with variables, other than directly assigning replacement values to the label. Replacements returned by this method have priority over direct values, unlessnull
is returned.- Specified by:
replaceVariable
in interfaceTypingListener
- Parameters:
variable
- The variable name assigned to the{VAR}
token. For example, in{VAR=townName}
, the variable will betownName
- Returns:
- The replacement String, or
null
if this method should be ignored and the regular values should be used instead. - See Also:
-
onChar
public void onChar(long ch) Description copied from interface:TypingListener
Called when a new character is displayed. May be called many times per frame depending on the label configurations and text speed. Useful to do a certain action each time a character is displayed, like playing a sound effect.- Specified by:
onChar
in interfaceTypingListener
-