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

2020/4/22

How to make person with the highest score win?

1
2
3
HairyChickens HairyChickens

2020/4/24

#
I think i figured out most of it. For player1score and player2score i replaced it with player_1.player1score and player_2.player2score and for the object placement i removed all of the world words because its in the World class so its not necessary. But I'm still not sure what i do for isTouching. I tried doing the same thing with the player_1.isTouching but it says "isTouching(java.lang.Class<?>) has protected access in greenfoot.Actor. " Please let me know if my modifications were correct.
    public void plutoTouched1()
    {
        if (player_1.player1score > player_2.player2score && player_1.isTouching(Pluto.class))
        {
            addObject(new Player_1_Wins(),getWidth()/2, getHeight()/2);
            Greenfoot.playSound("Victory.mp3");
            Greenfoot.stop();
        }
    }
danpost danpost

2020/4/25

#
Remove the isTouching checks from the methods in the world class. The players check that before calling the methods.
HairyChickens HairyChickens

2020/4/25

#
It works now !!! HONESTLY DANPOST THANK YOU SO MUCH YOU'RE ACTUALLY A LEGEND
HairyChickens HairyChickens

2020/4/25

#
I don't know if I should create another post on this but is it possible to create a highscore leader board using the scores. So I have a MainMenu world and I created a button that says Highscore and when its pressed it takes you to the HighscoreScreen World. I want the leader board to be in this world. If it is possible do you mind teaching me how to do it. Thanks
You need to login to post a reply.
1
2
3