![]() ![]() 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. But it keeps saying: : Could not open sound file: greenfoot.GreenfootSound1157edf file: break.mp3. Pada part 4 ini kita belajar bagaimana cara memberi music atau backsound pada sebuah game. It seems a bit redundant to have two arrays with exactly the same data. Jika di part3, Kita sudah belajar tentang bagaimana cara menggerakkan objek dengan keyboard dan mouse menggunakan greenfoot. But, the above should get your fields (which I renamed to more properly fit what they represent) and their references set up properly. Though, you could also shorten the code you currently have to: int position Greenfoot.getRandomNumber (3) addObject (new Grunt (), 125 +position125, 175) But the problem with your code currently is that it is placed in the worlds constructor, which only gets executed once (when the world is created). I am quite sure that things will need to be tended to there as well. ![]() It could be something like this: GreenfootSound gfs new GreenfootSound (soundFiles i+'.mp3') where you can then use gfs.play (), gfs.stop (), or any one of a number of object methods in the GreenfootSound class. This also does not presume that the rest of the class is fine and correct. The GreenfootSound constructor needs a string representing the full filename of the sound file. 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. Sound files must be placed the sounds folder of your Greenfoot project to be used in the game. Public PlayMusicButton(String soundFiles, String songNames, Color colors) If you don't have any SFX/music, look on itch.io for some free SFX To implement it in your game you need to use aySound('example. In the Component 2 exam of the WJEC / Eduqas 2016 specification, an audio file will be placed in the sounds folder already. Yo I am also a student but I looked on the forums for help So basically, you need to get a recording of your sound and then put it in the sounds folder of your greenfoot project. Public class PlayMusicButton extends Actor I am trying to create a simple mp3 player in green foot and use buttons to control the volume. Sound files must be placed the sounds folder of your Greenfoot project to be used in the game. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |