Skip to content

6. Animations

Maxim edited this page Jan 22, 2025 · 2 revisions

HologramLib provides a basic animation system for text holograms.

Creating Animations

Basic Animation

TextAnimation animation = new TextAnimation()
    .setDelay(20)    // Initial delay in ticks (higher number 
= longer delay)
    .setSpeed(20);   // Frame duration in ticks (higher number = slower)

animation.addFrame("Frame 1")
    .addFrame("Frame 2")
    .addFrame("Frame 3");

hologramManager.applyAnimation(textHologram, animation);

Typing Effect Animation

TextAnimation typingAnimation = new TextAnimation()
    .setDelay(5)
    .setSpeed(5);

typingAnimation.addFrame("H")
    .addFrame("He")
    .addFrame("Hel")
    .addFrame("Hell")
    .addFrame("Hello");

Color Changing Animation

TextAnimation colorAnimation = new TextAnimation()
    .setDelay(20)
    .setSpeed(20);

colorAnimation.addFrame("<red>Colored Text</red>")
    .addFrame("<blue>Colored Text</blue>")
    .addFrame("<green>Colored Text</green>")
    .addFrame("<yellow>Colored Text</yellow>");

Managing Animations

Starting Animations

// Apply and automatically start the animation
hologramManager.applyAnimation(textHologram, animation);

Modifying Frame Content

TextAnimation animation = new TextAnimation();

/* Add frames */
animation.addFrame("New Frame");

/* Remove frames */
animation.removeFrame(0);          // Remove by index
animation.removeFirstFrame();      // Remove first frame
animation.removeLastFrame();       // Remove last frame
animation.clearFrames();           // Remove all frames

Stopping Animations

hologramManager.cancelAnimation(textHologram);

Advanced Animation Techniques

Rainbow Text Effect

TextAnimation rainbowAnimation = new TextAnimation()
    .setDelay(5)
    .setSpeed(5);

String[] colors = {"<red>", "<gold>", "<yellow>", "<green>", "<aqua>", "<blue>", "<purple>"};
String text = "Rainbow Text";

for (String color : colors) {
    rainbowAnimation.addFrame(color + text);
}

Scrolling Text

TextAnimation scrollAnimation = new TextAnimation()
    .setDelay(5)
    .setSpeed(5);

String text = "This is scrolling text ";
int length = text.length();

for (int i = 0; i < length; i++) {
    String frame = text.substring(i) + text.substring(0, i);
    scrollAnimation.addFrame(frame);
}

Related Topics

Clone this wiki locally