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

2014/5/1

Help wiht the finish of the game

1
2
danpost danpost

2014/5/2

#
'counter', on line 30, is referring to a Counter object that is created at line 11 when the 'correctButton' object is being created. Remove line 11; and replace everything from line 26 through 50 with this;
if (Greenfoot.mouseClicked(this)) ((Timeworld)getWorld()).countScore();
BasseQ47 BasseQ47

2014/5/2

#
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
 import java.awt.*;  
/**
 * Write a description of class corretButtom here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class correctButton extends Actor
{
        
        private boolean onThis=false;  
        
        Questing_1 Questing_1 = new Questing_1();
        
        public void act()  
         {  
             
            if(Greenfoot.mouseMoved(null))  
            onThis = Greenfoot.mouseMoved(this);  
            if(onThis)  
            setImage("ButtonPressed.png");
            else  
            setImage("Buttonnotpress.png"); 
        
          if (Greenfoot.mouseClicked(this)) ((Timeworld)getWorld()).countScore(); 
          
        
       
           
                      }   
       }
i am getting a eorror method countscore in class Timeworld connot be applied to given types; required int; found no arguments; reason actual and formal argumen lists differ in length
danpost danpost

2014/5/2

#
danpost wrote...
'counter', on line 30, is referring to a Counter object that is created at line 11 when the 'correctButton' object is being created. Remove line 11; and replace everything from line 26 through 50 with this;
if (Greenfoot.mouseClicked(this)) ((Timeworld)getWorld()).countScore();
Sorry. make that:
if (Greenfoot.mouseClicked(this)) ((Timeworld)getWorld()).countScore(10);
BasseQ47 BasseQ47

2014/5/2

#
i am sorry i still don't get any point and now my buttons want disappear
danpost danpost

2014/5/2

#
Are you using the Timeworld class I posted or did you modify it? If you modified it, that post what you have now.
BasseQ47 BasseQ47

2014/5/2

#
i am not completely sure about what you mean so her is my Timeworld class and correctbutton class
import greenfoot.*;  // (World, Actor, GreenfootImage, and Greenfoot)
/**
 * Write a description of class world here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Timeworld extends World
{
    public Counter scoreCounter;
    int correctButton;
    int question;
   
    GreenfootSound backgroundmusic = new GreenfootSound("Zack Hemsey - Mind Heist Evolution.mp3");
   
      
       /**
     * Constructor for objects of class world.
     * 
     */
    public Timeworld()
    {    
        // Create a new world with 600x400 cells with a cell size of 1x1 pixels.
        super(1500, 900, 1); 
        
        Counter counter = new Counter();
        addObject(counter, 908,48);
        
   
        
        nextQuestion(); 
        
       
      
    }
    public void nextQuestion()  
    {  
     
        question ++;
        removeObjects(getObjects(buttonEorror.class));  
        removeObjects(getObjects(correctButton.class));  
        removeObjects(getObjects(Questing_1.class));  
        removeObjects(getObjects(Questing_2.class));  
        removeObjects(getObjects(Questing_3.class));  
        removeObjects(getObjects(Questing_4.class));  
        removeObjects(getObjects(Questing_5.class)); 
        
        if (question == 1)  
        {  
            addObject(new Questing_1(), 320, 300);  
            addObject(new correctButton(), 450, 430);  
            addObject(new buttonEorror(), 350, 430);  
            addObject(new buttonEorror(), 250, 430);  
            
        }  
        
        if (question == 2)  
        {  
            addObject(new Questing_2(), 320, 300);  
            addObject(new correctButton(), 250 ,430);  
            addObject(new buttonEorror(), 350, 430);  
            addObject(new buttonEorror(), 450, 430);  
            
        }  
        
        if (question == 3)         
        {  
            addObject(new Questing_3(), 320, 300);  
            addObject(new correctButton(), 250, 430);  
            addObject(new buttonEorror(), 350, 430);  
            addObject(new buttonEorror(), 450, 430);  
        } 
        
        if (question == 4)         
        {  
            addObject(new Questing_4(), 320, 300);  
            addObject(new correctButton(), 350, 430);  
            addObject(new buttonEorror(), 250, 430);  
            addObject(new buttonEorror(), 450, 430);  
        }  
        
        if (question == 5)         
        {  
            addObject(new Questing_5(), 320, 300);  
            addObject(new correctButton(), 250, 430);  
            addObject(new buttonEorror(), 350, 430);  
            addObject(new buttonEorror(), 450, 430);  
        }  
    }  
     public void started()  
    {  
     backgroundmusic.play();
    }  
    public void gameOver() 
    {
        addObject(new ScoreBoard(scoreCounter.getValue()),getWidth()/2,getHeight()/2);
         Greenfoot.playSound("Sons Of Odin - Patrick Doyle.mp3");
         if(backgroundmusic.isPlaying())  
         {  
             backgroundmusic.stop();  
            }  
    }
       public void countScore(int score)
    {
        scoreCounter.add(score);
        nextQuestion();
    }
    
     
}
    
   
     
   


import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
 import java.awt.*;  
/**
 * Write a description of class corretButtom here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class correctButton extends Actor
{
        
        private boolean onThis=false;  
        
        Questing_1 Questing_1 = new Questing_1();
        
        public void act()  
         {  
             
            if(Greenfoot.mouseMoved(null))  
            onThis = Greenfoot.mouseMoved(this);  
            if(onThis)  
            setImage("ButtonPressed.png");
            else  
            setImage("Buttonnotpress.png"); 
        
            if (Greenfoot.mouseClicked(this)) ((Timeworld)getWorld()).countScore(10); 
          
        
       
           
                      }   
       }
danpost danpost

2014/5/2

#
Please change lines 26 and 27 in your Timeworld class to this:
scoreCounter = new Counter();
addObject(scoreCounter, 908,48);
If that is causing a problem somewhere, please post the issue.
BasseQ47 BasseQ47

2014/5/2

#
YES Sir that was it now the Question spawns as they should so Cool Thanks
You need to login to post a reply.
1
2