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

2018/1/31

Separate scoreboard and timer for 3 classes

1
2
3
frequency frequency

2018/1/31

#
I want to make 3 different scoreboards,basically they do the same job but i want to use them in 3 different classes. And i want to make a timer in 3 different classes as well! Here is the scenario. I had to delete some code since it would not complile
frequency frequency

2018/1/31

#
The timers i want to make must start from 90seconds and -1-1-1 60seconds and -1-1-1 30seconds and -1-1-1
danpost danpost

2018/1/31

#
I do not know why you would want to create multiple classes that basically do the same thing. You really only need one class which you can create 3 scoreboards from. You can also use a single generic Actor subclass for all the buttons and timers. So, your project really only needs 3 Actor subclasses -- the generic one, the scoreboard one and the circle one.
frequency frequency

2018/1/31

#
http://prntscr.com/i874cn These are my actors!
danpost danpost

2018/1/31

#
frequency wrote...
http://prntscr.com/i874cn These are my actors!
Like I said, you only need 3 Actor subclasses. Also, you only need 2 World subclasses. Keep things simple.
frequency frequency

2018/1/31

#
I am sorry,but i cant move on from here.I made the scoreboard. Works.But it keeps the score even if i reset the game
danpost danpost

2018/1/31

#
You probably have either the scores or the Scoreboard itself in a static field. Show relevant codes.
frequency frequency

2018/1/31

#
I messed up,remove the static field and now it wont run or debug to share it to you. The only thing i can do is upload it to zippyshare again
frequency frequency

2018/1/31

#
You are my last hope with this. If you cant edit it,i cant do it. The only option is to edit it directly, the score and the image where i failed http://www37.zippyshare.com/v/IpYR9qYt/file.html
danpost danpost

2018/1/31

#
You can always comment out everything in all classes except for the class declarations and world constructor calls and upload it. That is, all Actor subclasses like this:
import greenfoot.*;

public class Circle()
{
    // comment out everything except for final closing squiggly bracket at bottom of code
}
and world classes like this:
import greenfoot.*;

public class World_90 extends World
{
    // comment out all fields

    public World_90()
    {
        super(600, 800, 1);
        // comment out the rest of the constructor code except closing bracket show on next line
    }

    // comment out everything else except closing bracket at end of code
}
danpost danpost

2018/1/31

#
frequency wrote...
You are my last hope with this. If you cant edit it,i cant do it. The only option is to edit it directly, the score and the image where i failed http://www37.zippyshare.com/v/IpYR9qYt/file.html
Another option is just to download what you uploaded 2 to 3 hours ago.
frequency frequency

2018/1/31

#
http://www.greenfoot.org/scenarios/20774 cant add the score in class 90!
danpost danpost

2018/1/31

#
frequency wrote...
http://www.greenfoot.org/scenarios/20774 cant add the score in class 90!
I do not think you put any code in the World_90 class like you did in the other two.
frequency frequency

2018/1/31

#
What? Its empty? The code is nearly the same
frequency frequency

2018/1/31

#
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class thirty_seconds here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class ninety_seconds extends Actor
{
    public static int score=0;
    boolean bla=false;
    public void act()
    {
        getWorld().setBackground(new GreenfootImage("back.png"));
        if(Greenfoot.mouseClicked(this))
        {
            Greenfoot.setWorld(new World_90());
        }
        if (Greenfoot.isKeyDown(" ") && bla==false){
            checkKeyboard();
            bla=true;
        }
        else if(!Greenfoot.isKeyDown(" ") && bla==true){
            bla=false;
        }
    }

    void checkKeyboard()
    {
        if (Greenfoot.isKeyDown("space"))
        {
            score=score+1;
        }
    }

    public static int getScore()
    {
        return score;
    }
    
}













thats it lol
There are more replies on the next page.
1
2
3