Welcome on MasterOf13FPS! MasterOf13FPS

Register today or sign up if you are already a member and never miss any cool content again :)

Tutorial Animations with easings.

can u send a base to do it? i don't understand how to use that ._.

Add an instance of the class Animation in your Module class
Code:
private final Animation animation = new Animation();

public void getAnimation(){return animation;}

Go to your arraylist and call the instance's update & animate method
Code:
module.getAnimation().update();

module.getAnimation().animate(fontrenderer.getStringWidth(module.getName()),300,Easings.BOUNCE_OUT);

Then change the parameter x of your drawString method call to width-module.getAnimation().getValue()
 
Add an instance of the class Animation in your Module class
Code:
private final Animation animation = new Animation();

public void getAnimation(){return animation;}

Go to your arraylist and call the instance's update & animate method
Code:
module.getAnimation().update();

module.getAnimation().animate(fontrenderer.getStringWidth(module.getName()),300,Easings.BOUNCE_OUT);

Then change the parameter x of your drawString method call to width-module.getAnimation().getValue()
Doesn't works, it animate every module just when i disable/enable my hud module
 
Doesn't works, it animate every module just when i disable/enable my hud module
You have to change the target when the module is off
Code:
if(module.isEnabled()){
module.getAnimation().animate(fontrenderer.getStringWidth(module.getName()),300,Easings.BOUNCE_OUT);
}else{
module.getAnimation().animate(0,300,Easings.BOUNCE_IN);
}

Also change the if in your arraylist from module.isEnabled to module.getAnimation().getValue() !=0

Btw without knowing your code we can not really help you
 
Add an instance of the class Animation in your Module class
Code:
private final Animation animation = new Animation();

public void getAnimation(){return animation;}

Go to your arraylist and call the instance's update & animate method
Code:
module.getAnimation().update();

module.getAnimation().animate(fontrenderer.getStringWidth(module.getName()),300,Easings.BOUNCE_OUT);

Then change the parameter x of your drawString method call to width-module.getAnimation().getValue()
actually use BACK_BOTH EASING
 
can u send a base to do it? i don't understand how to use that ._.
sd
Java:
package club.brucite.client.api.util.render;

import club.brucite.client.api.util.animation.Animation;
import club.brucite.client.api.util.animation.Easing;

/**
 * Created by Slosa
 * on 20.01.2022
 * for Brucite client
 */
public class Position2D {
    private double x, y;

    private final Animation animX = new Animation();

    private final Animation animY = new Animation();

    private boolean wasAnimated = false;

    public Position2D(final double x, final double y) {
        this.x = x;
        this.y = y;
    }

    public void animate(final double newX, final double newY, final double duration, final Easing easing) {
        if (!animX.isAlive() && !animY.isAlive() && wasAnimated) {
            wasAnimated = false;
        }

        if (!wasAnimated) {
            animX.setLastValue(x);
            animY.setLastValue(y);
            animX.animate(newX, duration, easing);
            animY.animate(newY, duration, easing);
            wasAnimated = true;
        }
        animX.updateAnimation();
        animY.updateAnimation();

        this.x = animX.getValue();
        this.y = animY.getValue();
    }

    public double getX() {
        return x;
    }

    public void setX(final double x) {
        this.x = x;
    }

    public double getY() {
        return y;
    }

    public void setY(final double y) {
        this.y = y;
    }


}
 
then just do what dirt said so
also for x and y use module.position2d.getX and getY
 
Can u do an exemple
lol.bro.
sooooooo, lets make a tutorial for this thing without using any shitty crutches. but, these crutches can help u remove alot of lines of code.

U need to create 2 animations in your module class
Java:
@Getter /* Use lombok, or generate getters for it, like:
public Animation getYPos() {
    return yPos;
}
*/
private Animation yPos;
@Getter /* Use lombok, or generate getters for it, like:
public Animation getXPos() {
    return xPos;
}
*/
private Animation xPos;

Then u need to do an update method which will animate your xPos
Java:
// i'll use distance between right side of screen and module name in 5 pixels
private final double distance = 5.0;

// this.getName() returns module name

public void updatePos() {
    if (this.isEnabled()) { // Check if module is enabled
        if (this.getXPos().getTarget() != fontrenderer.getStringWidth(this.getName()) + distance) { // fix lagging problem
            this.getXPos().animate(fontrenderer.getStringWidth(this.getName()) + distance, 350.0D, Easings.QUAD_BOTH);
        }
    } else if (this.getXPos().getTarget() != -distance) {
        this.getXPos().animate(-distance, 350.0D, Easings.QUAD_BOTH);
    }
}

then, u need go to your arraylist/hud class and in render event u need use like this
Java:
int index = 0;
Iterator modules = moduleList.iterator();

while(modules.hasNext()) {
    Module module = (Module) modules.next();
    module.getXPos().updateAnimation(); // Updating xpos anim
    module.getYPos().updateAnimation(); // Updating ypos anim
    module.updatePos(); // using method which we created
    if (module.getYPos().getTarget() != distance + y) {
        module.getYPos().animate(distance + y, 350.0D, Easings.QUAD_BOTH);
    }

    if (!(module.getXPos().getValue() <= distance)) {
        Gui.drawRect((double)sr.getScaledWidth() - module.getXPos().getValue() - 8.0D, module.getYPos().getValue(), (double)sr.getScaledWidth() + fontrenderer.getStringWidth(module.getName()) - module.getXPos().getValue(), module.getYPos().getValue() + 4.0D + (double)fontrenderer.FONT_HEIGHT + 2.0D, new Color(0, 0, 0, 125).getRGB()); // drawing rect
        fontrenderer.drawStringWithShadow(module.getName(), (double)(sr.getScaledWidth() - 5) - module.getXPos().getValue(), (float)(module.getYPos().getValue() + 2.0D + (double)(fontrenderer.getHeight() / 2)), color); // drawing text
        y += (double)(fontrenderer.FONT_HEIGHT + 6);
        ++index;
    }
}

so, prob this method is sooooo bad coz i wrote it in 5 seconds, but anyway, it works.
i used this shitty method in lorious, u can find src of this peaceofshit on this forum.

if u have any problems, no one can help u, coz this task is not hard
 
i'll try update animations and add some crutches for newbies. so, wait :>
 
shape1
shape2
shape3
shape4
shape5
shape6
Back
Top