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. You can only use the sounds that are stored in the Greenfoot library. Use: aySound ('pew.wav') to play the sound to allow multiple 'pew' sounds to play simultaneously. Most files of the following formats are supported: AIFF, AU, WAV, MP3 and MIDI. The sound cannot be played several times simultaneously, but can be played several times sequentially. A GreenfootSound loads the audio from a file. If you try 'pew.play ()' while pew is already playing, it does not restart or play again. Represents audio that can be played in Greenfoot. move line 4 to before line 1 so you only. Each time you call the method, you are creating a new (and different) GreenfootSound object which is not what you want (obviously). When it plays 3, it just says 'th' and it misses two and then it says 1 and go prefectly. The problem is that the GreenfootSound object you just created on line 4 could not be playing (you just created it, so how could it be playing). A simple class code might be something like this. 4 I think you should simplify matters by ridding yourself of all the method calls. You cannot record unique sounds in Greenfoot. This line creates one, and only one, instance of the sound. Update, I have got all 3 in my greenfoot sounds folder with those exact names. True or false Mark for Review (1) Points True () False Correct Correct 11. It seems a bit redundant to have two arrays with exactly the same data. In Greenfoot, the sound file must be saved in the scenario and written in the source code for it to play. Also you may want to fix line 47 if you want random number from -5 to 5 it should be: int newX Greenfoot. But, the above should get your fields (which I renamed to more properly fit what they represent) and their references set up properly. You have aysound ('fallenthing.wav'), It should be aySound ('fallenthing.wav') (Note that the 'S' in sound should be capitalized). I am quite sure that things will need to be tended to there as well. If you have ever found adding sound into Greenfoot difficult then this short video will give you the confidence you need. 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 youre only using the blue circle to play sound, then the coding for. The button is for decoration and is an object that produces sound (because the button class creates the sound). If(!selected & Greenfoot.mouseClicked(this)) This shows the adjustments to the beginning of your class. If the sound only activates from pressing the arrow keys, then what is the point of the blue circle in the middle of the frame (unless its just decoration). Public PlayMusicButton(String soundFiles, String songNames, Color colors) Public class PlayMusicButton extends Actor
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |