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

2013/5/22

Game error

1
2
3
4
5
JetLennit JetLennit

2013/5/23

#
Did you put the sound in the sound file?
geekykid2013 geekykid2013

2013/5/23

#
yep! :)
geekykid2013 geekykid2013

2013/5/23

#
only background thou. my laptop doesn't have enough memory to play button sounds
JetLennit JetLennit

2013/5/23

#
Do you have the sound on?
geekykid2013 geekykid2013

2013/5/23

#
it's looping thru I have not added the controls yet. I have put the code syntax into the world but not physically created the controls to max and min background sound
danpost danpost

2013/5/23

#
Looks like you had two balls being created in the SquareWorld class. Replace your SquareWorld code with the following:
import greenfoot.*;
import java.awt.Color;

public class SquareWorld extends World
{
    private Counter counter;
    private HealthBar healthBar;
    private Paddle paddle;
    private Robot robot;
    GreenfootSound backgroundMusic = new GreenfootSound("breathe.mp3");

    public SquareWorld()
    {  
        this(null); 
        backgroundMusic.playLoop();
    } 

    public SquareWorld(Robot inRobot)
    {
        super(700, 700, 1, true);
        setPaintOrder ( Robot.class, Smoke.class );
        if (inRobot == null)
        {
            Counter = new Counter();
            healthBar = new HealthBar ("Robot Health", "", 100, 100);
            robot = new Robot(counter, healthBar);
        }
        else
        {
            counter = inRobot.getCounter();
            healthBar = inRobot.getHealthBar();
            robot = inRobot;
        }
        addObject(counter, 100, 678);
        addObject(healthBar, 600, 678);
        addObject(robot, getWidth()/2, getHeight()-90);
        paddle = new Paddle(robot);
        addObject(paddle, getWidth()/2, getHeight()-55);
    }
    
    private void prepare()
    {
        addObject(new goldEgg(), 309, 397);
        addObject(new goldEgg(), 308, 182);
        addObject(new goldEgg(), 458, 259);
        addObject(new goldEgg(), 552, 95);
        addObject(new goldEgg(), 143, 91);
        addObject(new goldEgg(), 142, 258);
        addObject(new goldEgg(), 555, 411);
        addObject(new goldEgg(), 232, 332);
        addObject(new goldEgg(), 346, 286);
        addObject(new goldEgg(), 144, 486);
        addObject(new goldEgg(), 386, 483);
        addObject(new goldEgg(), 553, 259);
        addObject(new goldEgg(), 388, 91);
        addObject(new yellowEgg(), 389, 181);
        addObject(new yellowEgg(), 453, 332);
        addObject(new yellowEgg(), 553, 185);
        addObject(new yellowEgg(), 230, 184);
        addObject(new yellowEgg(), 231, 392);
        addObject(new yellowEgg(), 553, 490);
        addObject(new blueEgg(), 307, 93);
        addObject(new blueEgg(), 143, 332);
        addObject(new blueEgg(), 458, 187);
        addObject(new blueEgg(), 141, 182);
        addObject(new blueEgg(), 381, 395);
        addObject(new blueEgg(), 554, 335);
        addObject(new blueEgg(), 461, 481);
        addObject(new redEgg(), 227, 92);
        addObject(new redEgg(), 462, 88);
        addObject(new redEgg(), 233, 260);
        addObject(new redEgg(), 454, 394);
        addObject(new redEgg(), 304, 486);
        addObject(new redEgg(), 227, 485);
        addObject(new redEgg(), 142, 408);
    } 
}
I did not change any of the functionality of the code (just cleaned it up a bit and removed the duplicated creation of the Robot object).
geekykid2013 geekykid2013

2013/5/23

#
I now receive the error - class, interface, or enum expected - in the private void prepare() method as above when I compile
geekykid2013 geekykid2013

2013/5/23

#
The code for the last post is the same as above. only the error is from the private void prepare() method the error is class, interface, or enum expected
danpost danpost

2013/5/23

#
I bet you either are missing a bracket or have one too many brackets '{' or '}'. Probably one too many closing brackets just before the prepare method.
geekykid2013 geekykid2013

2013/5/23

#
I am getting an exceptions error in my MenuButton now that i have put in the sound file. I have added the Greenfoot.playSound("ContinueButton");
java.lang.IllegalArgumentException: Could not open sound file: ContinueButton
	at greenfoot.sound.SoundExceptionHandler.handleIOException(SoundExceptionHandler.java:66)
	at greenfoot.sound.SoundFactory.createSound(SoundFactory.java:120)
	at greenfoot.Greenfoot.playSound(Greenfoot.java:162)
	at MenuButton.act(MenuButton.java:20)
	at greenfoot.core.Simulation.actActor(Simulation.java:565)
	at greenfoot.core.Simulation.runOneLoop(Simulation.java:523)
	at greenfoot.core.Simulation.runContent(Simulation.java:213)
	at greenfoot.core.Simulation.run(Simulation.java:203)
Caused by: java.io.FileNotFoundException: Could not find file: ContinueButton
	at greenfoot.util.GreenfootUtil.getURL(GreenfootUtil.java:534)
	at greenfoot.sound.SoundFactory.createSound(SoundFactory.java:99)
	... 6 more
danpost danpost

2013/5/23

#
Does your sound file have an extension to its name?
geekykid2013 geekykid2013

2013/5/23

#
ContinueButton.mp3 - you are right I forgot to include the extension
geekykid2013 geekykid2013

2013/5/23

#
I adding my egg objects to the SquareWorld() but when I save to the World nothing is saved is there a reason for this?
geekykid2013 geekykid2013

2013/5/23

#
I added my egg objects to the SquareWorld(); but when I Save To World nothing is saved in my world is there a reason for this~?
danpost danpost

2013/5/24

#
Comment out the prepare method and the prepare call in the constructor and try again.
There are more replies on the next page.
1
2
3
4
5