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

2024/2/6

Points System

Kookaburra737 Kookaburra737

2024/2/6

#
Hey! I'm trying to make a mini-game where a lizard has to sit on a road to gain heat and if he reaches a certain heat the game ends but I can't figure out how to Display the Heat/score, I read the notes in the displaying values tutorial but I'm having trouble understanding the concept. Can someone please help me? This is what code I have;
    private int Temp = 0;
        void Temperature()
    {
        if (isTouching(Road.class))
        {
            Temp = Temp+1;
            
        }
    }
danpost danpost

2024/2/8

#
Kookaburra737 wrote...
I can't figure out how to Display the Heat/score, I read the notes in the displaying values tutorial but I'm having trouble understanding the concept.
There are only two ways to display anything in your world using greenfoot. One is changing the background image of the World itself (not recommended) and the other is by using the image of an Actor type object. The Actor object will need to be retained in an Object reference variable -- in a field, for example:
privare Actor tempDisplay;
Have it added into the world when the lizard object is added into the world and set its initial image. Change its image anytime the Temp field value changes to update the displayed value.
You need to login to post a reply.