![]() ![]() Player have to move a character to left or right where there are 2 boxes, with 'true' or 'false', if he wrongs I want play a sound, if he is right, then play another. 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. Hy to all, is that possible to make greenfoot play a soudn only if one actor touches another one. Greenfoot provides a GreenfootSound class to help easily manage audio. It doesnt work :/ : Could not open sound file: Strength of a Thousand Men Caused by: java.io. 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. 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. Ive been trying to add a sound effect for when the sitckman reaches the edge but no sound will play. If(!selected & Greenfoot.mouseClicked(this)) This shows the adjustments to the beginning of your class. I am making an attempt at a stickman scenario and when the stickman hits either end, it dies. 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). Public PlayMusicButton(String soundFiles, String songNames, Color colors) 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 GreenfootSound loads the audio from a file. Public class PlayMusicButton extends Actor 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 |