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

2021/5/12

How to print string on the world

Jemy Jemy

2021/5/12

#
I want to print a string of text on the world based on a fulfilment of a condition. i have done the following in my Server class. if it's okay how can i call it on the World class
1
2
3
4
5
6
7
public String electionStatus(){
        if(getVotesGranted() >= qourum){
            return "Election Successful";
        }else{
           return "Election Fail";
        }
    }
RcCookie RcCookie

2021/5/12

#
To show a string on the world:
1
world.showText(text, x, y);
To create an image with the text that which an actor may use:
1
2
3
GreenfootImage image = new GreenfootImage(text, fontSize, textColor, backgroundColor);
// for example
image = new GreenfootImage("Hello World!", 20, Color.BLACK, new Color(0,0,0,0));
Jemy Jemy

2021/5/12

#
RcCookie wrote...
To show a string on the world:
1
world.showText(text, x, y);
To create an image with the text that which an actor may use:
1
2
3
GreenfootImage image = new GreenfootImage(text, fontSize, textColor, backgroundColor);
// for example
image = new GreenfootImage("Hello World!", 20, Color.BLACK, new Color(0,0,0,0));
Thanks for your help. let me try it
You need to login to post a reply.