This site requires JavaScript, please enable it in your browser!
Greenfoot back
31n5t31nn
31n5t31nn wrote ...

2022/2/20

TEXT ANIMATION

31n5t31nn 31n5t31nn

2022/2/20

#
Hello , I'm new to programming and especially greenfoot , i don't really know how to create and animate a text to be more specific im trying to create a "Select champion" text at the start of thee game.All help is appreciated!
RcCookie RcCookie

2022/2/20

#
Creating animations is very difficult in Greenfoot because you have to do all scaling, drawing and updating manually. But for a simple button you could use something like this:
public class Button extends Actor {
    public Button() {
        // 0000 for transparent background
        setImage(new GreenfootImage("Select champion", 24, Color.RED, new Color(0,0,0,0)));
    }

    public void act() {
        if(Greenfoot.mouseClicked(this)) onClick();
    }

    private void onClick() {
        // Your code here
    }
}
If you need more than one button you may want to use abstract classes or lambdas to generify the action and title of the button.
You need to login to post a reply.