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

2021/3/30

How do I align text to the left?

mkdaniel mkdaniel

2021/3/30

#
setImage(new GreenfootImage(skills[PickP.a][0] + "\n" + skills[PickP.a][1]+ "\n" + skills[PickP.a][2]+ "\n" + skills[PickP.a][3], 25, Color.BLACK, null));
    }    
Currently, the text align to the center, but I want it align to the left. Does anyone know the way to do it? Thanks. Flamethrower Roar Cut Flame Wheel array skills is storing string and PickP.a is int from different class.
String skills[][] = {{"Flamethrower", "Roar", "Cut", "Flame Wheel"},
            {"Solar Beam", "Mega Drain", "Razor Leaf", "Tackle"},
            {"Bite", "Hydro Pump", "Surf", "Iron Defense"},
            {"Tackle", "Spark", "Thunder Bolt", "Screech" }}; 
danpost danpost

2021/3/30

#
mkdaniel wrote...
Currently, the text align to the center, but I want it align to the left. Does anyone know the way to do it?
Create an array of GreenfootImage objects and fill it with individual text images. Then create one large GreenfootImage object whose width is that of the widest text image and whose height is that of one text image multiplied by the number of text images. Finally, draw each text image onto the large image starting along left edge.
You need to login to post a reply.