Better is to create and keep a reference to a GreenfootSound object which you can control. Kirito101, please show how you are trying to use those method, including what you are. It just tells me meathod start () stop () ect. With that, however, you have no control over it - it will play until completed (unless you close the project outright). If you have got a reference of the soud you just have to write: SoundName.stop () or if you just want is to take a break you write: SoundName.pause () how do you get greenfootSound. I did try to change or add the extend to World, but I am not doing something right because it will not accept it. The simplest way is to use aySound ( / string filename of music file / ). just copy all your sound files into the folder sounds in your project folder, then you can use them in your code with aySound ('sound.mp3') or ayLoop () if song is an GreenfootSound. You will have to copy/paste them into the sounds directory of your project. 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. Sound files must be placed the sounds folder of your Greenfoot project to be used in the game. Greenfoot does not have an import function for sound files. To gain more control over the music, you must create and retain a GreenfootSound object in a field so you can call methods of the. It will only stop when you re-compile or leave the app. 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. 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. 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"). 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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |