If you are using aySound('Theme1.mp3') to start the music, then because you do not retain a reference to the sound, you cannot stop it. You cannot place anything between the parenthesis when calling stop (only usage: Greenfoot.stop() ). The class is provided by greenfoot and the method is in that class. aySound () Andriyanto How to stop aySound ('xxxx') i make a sound but i don't know how to stop aySound () when i click button next, can help me Andriyanto i want, when i click button next, so aySound () stop. The stop method in the Greenfoot class does not take any parameters. The other words you may not 'know' are GreenfootSound (a class name) and playLoop (a method name). which can be shortened to this: ( (MyWorld)getWorld ()).music.stop () This presumes you named the GreenfootSound object in MyWorld as music : public GreenfootSound music new GreenfootSound ('Music. Triggering a sound on an event, in this case a . The only 'computer' word I used was method and you should know what that is. The exeption is only thrown if I play soundfiles longer than about 1 minute. 3.5K views 6 years ago Greenfoot tutorials. I did try to change or add the extend to World, but I am not doing something right because it will not accept it.I've got a problem with some GreenfootSounds: sometimes I get this exception:Įxception in thread "SoundStream:file:/D:/Daten/Schule/Informatik/Java/Greenfoot-Szenarien/StarWars%20Szenarios/Star%20Wars%20Szenario%20V6.6/sounds/Mass%20Effect%203%20Soundtrack%20-%20The%20View%20of%20Palaven%20OST%20Music%205-2.mp3" : Could not open sound file: file:/D:/Daten/Schule/Informatik/Java/Greenfoot-Szenarien/StarWars%20Szenarios/Star%20Wars%20Szenario%20V6.6/sounds/Mass%20Effect%203%20Soundtrack%20-%20The%20View%20of%20Palaven%20OST%20Music%205-2.mp3Īt (SoundExceptionHandler.java:66)Īt (SoundStream.java:374)Ĭaused by: java.io.IOException: javazoom.jl.decoder.BitstreamException: Bitstream errorcode 102Īt (Mp3AudioInputStream.java:223)Īt (SoundStream.java:302) I don't know yet about the second question, as in I don't understand it yet :)Īnd, yes, it stops immediately after I click on the 'Run' button. The world and actors are represented by Java objects and defined by Java classes. Thank you for the reply, I checked if I maybe put it in more than one place, and it is only once in the Lobster. The Greenfoot programming model consists of a World class (represented by a rectangular screen area) and any number of actor objects that are present in the world and can be programmed to act independently. ![]() The thing is that I am probably missing something, because no mater where I put it, it stops the game immediately and not when the Lobster eats the Crab.Where did you try to place the 'Greenfoot.stop() ' line? Did you place the line in more than one place in your code and forgot to remove one (possibly in a different class)? Is it stopping due to a thrown exception (does the terminal show up with a stack trace)? If it stops immediately after you click on the 'Run' button, you should probably show the code to your World subclass (class that "extends World"). In answer to your second one, its easier to use the Greenfoot.getRandomNumber method, which takes the limit as argument (limit is not included in the result, 0 is included): int position Greenfoot.getRandomNumber (3) // will return either 0, 1 or 2 (never 3) // the rest. Also you may want to fix line 47 if you want random number from -5 to 5 it should be: int newX Greenfoot. The UserInfo class can be used to store data permanently on a server, and to share this data between different users, when the scenario runs on the Greenfoot web site. You have aysound ('fallenthing.wav'), It should be aySound ('fallenthing.wav') (Note that the 'S' in sound should be capitalized). This class contains information about the current status of the mouse. Method Summary int: getVolume() Get the current volume of the sound, between 0 (off) and 100 (loudest.) boolean: isPlaying() True if the sound. Represents audio that can be played in Greenfoot. ![]() ![]() The sound cannot be played several times simultaneously, but can be played several times sequentially. A GreenfootSound loads the audio from a file. Miro29 wrote.I want to stop the game after the Crab eats the Worm, and for that in the Greenfoot manual I found the Greenfoot.stop() method. Represents audio that can be played in Greenfoot.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |