Package com.github.tommyettinger.textra
Class TypingAdapter
java.lang.Object
com.github.tommyettinger.textra.TypingAdapter
- All Implemented Interfaces:
TypingListener
public class TypingAdapter extends java.lang.Object implements TypingListener
Simple listener for label events. You can derive from this and only override what you are interested in.
-
Constructor Summary
Constructors Constructor Description TypingAdapter() -
Method Summary
Modifier and Type Method Description voidend()Called when the char progression reaches the end.voidevent(java.lang.String event)Called each time anEVENTtoken is processed.voidonChar(long ch)Called when a new character is displayed.java.lang.StringreplaceVariable(java.lang.String variable)Called when variable tokens are replaced in text.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
TypingAdapter
public TypingAdapter()
-
-
Method Details
-
event
public void event(java.lang.String event)Description copied from interface:TypingListenerCalled each time anEVENTtoken is processed.- Specified by:
eventin interfaceTypingListener- Parameters:
event- Name of the event specified in the token. e.g. {EVENT=player_name} will have player_name as argument.
-
end
public void end()Description copied from interface:TypingListenerCalled when the char progression reaches the end.- Specified by:
endin interfaceTypingListener
-
replaceVariable
public java.lang.String replaceVariable(java.lang.String variable)Description copied from interface:TypingListenerCalled 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, unlessnullis returned.- Specified by:
replaceVariablein interfaceTypingListener- Parameters:
variable- The variable name assigned to the {VAR} token. For example, in {VAR=townName}, the variable will be townName- Returns:
- The replacement String, or
nullif this method should be ignored and the regular values should be used instead. - See Also:
TypingLabel.setVariable(String, String),TypingLabel.setVariables(java.util.Map),TypingLabel.setVariables(com.badlogic.gdx.utils.ObjectMap)
-
onChar
public void onChar(long ch)Description copied from interface:TypingListenerCalled 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:
onCharin interfaceTypingListener
-