Search in sources :

Example 1 with SlowTextElement

use of com.agorria.shootandmove.menu.SlowTextElement in project ShootAndRun by IonAgorria.

the class GameUI method showText.

/**
 * Shows text in UI
 */
void showText(String text) {
    if (text != null) {
        List<String> lines = Arrays.asList(Utilities.getTextLines(text));
        if (slowTextElement == null) {
            slowTextElement = new SlowTextElement(new Rectangle(aspect * 0.3f, 0.0f, aspect * 0.4f, 0.5f), lines, () -> showText(null), true, false);
            slowTextElement.onOpen();
        } else if (!text.equals(lastText)) {
            slowTextElement.setLines(lines);
        }
    } else {
        slowTextElement = null;
    }
    lastText = text;
}
Also used : DrawableRectangle(com.agorria.shootandmove.graphics.DrawableRectangle) Rectangle(com.agorria.shootandmove.math.Rectangle) SlowTextElement(com.agorria.shootandmove.menu.SlowTextElement)

Aggregations

DrawableRectangle (com.agorria.shootandmove.graphics.DrawableRectangle)1 Rectangle (com.agorria.shootandmove.math.Rectangle)1 SlowTextElement (com.agorria.shootandmove.menu.SlowTextElement)1