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

2017/4/3

Please Help!!

jhc0327 jhc0327

2017/4/3

#
public void act()
    {
       boolean guess = false;
       
       if(!guess){          
           if(isDown == false && Greenfoot.isKeyDown("space"))
           {
               currSong = Random();
               Greenfoot.playSound(songs[currSong] + ".mp3");
               isDown = true;
            }
       }
       
       if(guess){
           if(isDown == true && Greenfoot.isKeyDown("space")== false)
           {
               isDown = false;
           }
       }
       
       if(String.valueOf((currSong + 1)).equals(Greenfoot.getKey()) )
       {
           if(!guess){
               isDown = true;
               scr.addScore(5);
               guess = true;
            }           
           else if(guess != true){
               Greenfoot.setWorld(new Gameover());
            } 
        }
            
       if(guess){
           if(isDown == false && Greenfoot.isKeyDown("space")== true)
           {
               Greenfoot.playSound(songs[currSong] + "mp3");
               isDown = true;
               guess = true;
           }
           if(guess = true)
           {
               isDown = false;
           }
} The gameover screen isn't working ;((
Super_Hippo Super_Hippo

2017/4/3

#
Generally, you should describe your problem instead of saying "it is not working". What I can tell you from your code is that 1. line 3 should be outside the method 2. line 29 will never be executed because the condition in line 23 is the same as in 28
You need to login to post a reply.