i am adding sound to my object but when i compile and run greenfoot i get a runtime error. the sound file is working fine and in .wav format. how can i amend this problem?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | public class Ball extends Actor { private int deltaX; private int deltaY; /** * Create a ball with random movement */ { deltaX = Greenfoot.getRandomNumber( 11 ) - 5 ; deltaY = Greenfoot.getRandomNumber( 11 ) - 5 ; } /** * Act, Move and Produce Smoke * */ public void act() { makeSmoke(); // use this code to declare make smoke move(); // use this code to declare your object to move } /** * Move the ball. Then check whether we've hit a wall */ public void move() { setLocation (getX() + deltaX, getY() + deltaY); checkWalls(); // use this code to check that the object has hit a wall Greenfoot.playSound( "breathe.wav" ); } /** * Produce a puff of smoke */ public void makeSmoke() { getWorld().addObject ( new Smoke(), getX(), getY()); } /** * Check whether we've hit one of the walls. Reverse direction if necessary */ private void checkWalls() { if (getX() == 0 || getX() == getWorld().getWidth()- 1 ) { deltaX = - deltaX; } if (getY() == 0 || getY() == getWorld().getHeight()- 1 ) { deltaY = - deltaY; } } } |