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

2014/3/30

Passing a score from one world to another?

3
4
5
6
danpost danpost

2014/3/31

#
.
trias95 wrote...
Yeah i understand that it doesnt need to be passed back in order to play again i was just curious as to why you want the TryAgain class to acquire the counter as that class is simply a button to replay the game.
That was part of what I believe was a misunderstanding.
trias95 trias95

2014/3/31

#
hmm. man this has been a long ass thing huh :') im in college tomorrow. imma get my tutor to give it a shot. i belive youve got it right and you know what youre doing, i think its me, i dont seem to understand a lot of the instructions you give me as to how to fix :/
danpost danpost

2014/3/31

#
Like I said, it was just a misunderstanding. All you have to do is 'Greenfoot.setWorld(new Background())' to start a new play (from the GameOver world -- possibly in the 'TryAgain' button class for when clicked).
danpost danpost

2014/3/31

#
You can simplify your Background class back to this:
public class Background extends World
{
    static GreenfootSound music;
    static
    { 
        music = new GreenfootSound("inGameMusic.mp3");
        music.setVolume(50);
    }  

    Counter counter = new Counter();

    public Background()
    {
        super(800, 600, 1); 
        Start.title.stop();
        prepare();
    }

    private void prepare()
    {
        addObject(counter, 335,11);
        addObject(new Survivor(), 391, 323);
        addObject(new Spawner(), 89, 311);
        addObject(new scoreboard(), 715, 535);
    }
    
    public void act()
    {
        if(!music.isPlaying()) music.playLoop();
    }

    public Counter getCounter()
    {
        return counter;
    }
}
trias95 trias95

2014/4/1

#
Its fixed! the scenario is re-uploaded with the fix. What i did was went back to the counter static score method. i made the try again button take you to the start screen and the start button extend counter and set the static to 0 :) Ty for your help man :) Hoping to get an distinction in this assignment :3
You need to login to post a reply.
3
4
5
6