Play stop sound greenfoot3/7/2024 * turn a bit left or right by a random degree. * Randomly decide to turn from the current direction, or not. * Check whether we are at the edge of the world. However - if you can get your movie in GIF format (youll have to have the sound separate, if at all), you can use the new importable class that can display GIFs: go to Edit->Import Class. Just by using the method play, it will play just one time there is no need to stop or pause it. Making a GreenfootSound object will allow the methods in its class to control the sound object. * In this version, we have added a sound effect, and the game stops when Right now, its not easy, and if you want it to work on the site, its impossible. The sound.stop() command is stopping the same GreenfootSound object that ay() started however, unless the value of playno is changed again or the actor created from the class the given code is within is removed from the world, the first if block will re-start the sound, making it appear not to stop at all. I believe the Greenfoot method playSound causes the sound to be looped automatically and there is no control over that sound once it is started. Import greenfoot.* // (World, Actor, GreenfootImage, and Greenfoot) The way I have it now, the sound loops really fast and freezes up the scenario. The sound will run until it is complete played you will not even be able to find out whether it has stopped or not. If you use this method to play a sound, you will not have a reference to the sound object so you cannot run any method on it. I am supposed to make the loop terminate after 1000000000 executions. The Greenfoot method playSound does not allow you to do anything with the sound. We were instructed to use a while loop between the playing of the sound files, define an integer variable and increment it in the loop. instead of: aySound ('sound. Because i put the songs in the buttons of each scenario, so. I am trying to make it where when the lobster eats the crab, it plays the "slurp" file then plays the "fanfare" file. To stop it or pause it you have to use the class GreenfootSound. And stop the menu music when the game start or when credits button is pressed and the world changes to credit screen. I am running the crab program from the Introduction to Programming with Greenfoot. You could probably eliminate either the 'soundFiles' or the 'songNames' array and use the same data for both creating the sound objects and displaying their names.I am new to programming and I am currently trying to insert a while loop between 2 sounds to provide a short delay between them. It seems a bit redundant to have two arrays with exactly the same data. But, the above should get your fields (which I renamed to more properly fit what they represent) and their references set up properly. I am quite sure that things will need to be tended to there as well. This also does not presume that the rest of the class is fine and correct. I presumes that your sound files are ".mp3" files - if not, you need to make the necessary correction. If(!selected & Greenfoot.mouseClicked(this)) This shows the adjustments to the beginning of your class. The newGame button starts the game, so I need to stop the Music, when this button is clicked. The actual game has got another sound in the background, so I need to stop the Main Menu theme when I start the game. Public PlayMusicButton(String soundFiles, String songNames, Color colors) I tried to make a main Menu, with a sound in the background. Public class PlayMusicButton extends Actor
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |