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

2018/4/9

Scale(int, int)

Lavenger Lavenger

2018/4/9

#
I'm trying to scale the button image down after adding the button in, but it seems like I'm doing something wrong, can somebody help explain to me what did I do wrong here? This code
Buttons[i].scale(30, 30);
in particular has
.scale
underlined and an error message cannot find symbol - method scale(int,int) comes out This is the code that I'm using to call out the buttons:
public class MyWorld extends World
{
    private Actor MKButton = new SimpleActor(), HButton = new SimpleActor(), BButton = new SimpleActor(), AButton = new SimpleActor(), SButton = new SimpleActor(), KButton = new SimpleActor(), EButton = new SimpleActor(), TButton = new SimpleActor();
    Actor Buttons[] = {MKButton, HButton, BButton, AButton, SButton, KButton, EButton, TButton};
    private int ButtonsArraySize = Buttons.length;
    
    public MyWorld()
    {
        for( int i = 0; i <= ButtonsArraySize; i++)
        {
            Buttons[i].setImage(Buttons[i] + ".png"); Buttons[i].scale(30, 30); addObject(Buttons[i], 1200, (70 + (i*50)));
            i++;
            Buttons[i].setImage(Buttons[i] + ".png"); Buttons[i].scale(30, 30); addObject(Buttons[i], 1300, (70 + ((i-1)*50)));
        }
    }
}
danpost danpost

2018/4/9

#
Apparently, your Butttons array holds Actor objects and you cannot scale an actor (you scale the image assigned to the actor -- or GreenfootImage objects).
Lavenger Lavenger

2018/4/9

#
danpost wrote...
Apparently, your Butttons array holds Actor objects and you cannot scale an actor (you scale the image assigned to the actor -- or GreenfootImage objects).
oh that's right xD I was scaling the actor and not the image lol that's why it wasn't working
You need to login to post a reply.