![]() ![]() 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. Choose high quality music (MP3 or WAV) and sound effects (WAV) 01. It seems a bit redundant to have two arrays with exactly the same data. One int field to keep track of the count of how many sounds have yet to be played (initially set to number of sounds, or length of sound array). One Actor field for correct button (initially set to null). But, the above should get your fields (which I renamed to more properly fit what they represent) and their references set up properly. One array for all buttons (same order as sounds). ![]() ![]() I am quite sure that things will need to be tended to there as well. If you try 'pew. I cant see anything else that might be wrong. Try making a new sound file, maybe in a different format, and if that doesnt work, maybe restart your computer. This also does not presume that the rest of the class is fine and correct. GreenfootSound pew new GreenfootSound ('pew.wav') This line creates one, and only one, instance of the sound. I think that either something is wrong with the sound file itself, or something else is going on with your computer. 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. 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. Public PlayMusicButton(String soundFiles, String songNames, Color colors) The GreenfootSound constructor needs a string representing the full filename of the sound file. Is playing: falseĪt (GreenfootUtil.java:532)Īt (SoundFactory.Public class PlayMusicButton extends Actor (World, Actor, GreenfootImage, Greenfoot and MouseInfo) / Write a description of class HomeworkWorld here. Is playing: falseĪt (SoundExceptionHandler.java:66)Īt (SoundFactory.java:115)Īt (SoundFactory.java:130)Īt (Greenfoot.java:163)Īt Asteroids.check_hit(Asteroids.java:48)Īt (Simulation.java:507)Īt (Simulation.java:470)Īt (Simulation.java:204)Īt (Simulation.java:194)Ĭaused by: java.io.FileNotFoundException: Could not find file: file: break.mp3. I am having a problem with this too can someone please help. : Could not open sound file: file: break.mp3. Triggering a sound on an event, in this case a. ![]() GetWorld().addObject(new Asteroids(size/2, Greenfoot.getRandomNumber(3) + 1, Greenfoot.getRandomNumber(45) + 45, Greenfoot.getRandomNumber(360)), getX(), getY()) I am working on a simple car game on greenfoot and I wanna add an alert sound if my car is getting closer to a truck. 3.5K views 6 years ago Greenfoot tutorials. If(split.isPlaying()) aySound("" + split) Public Asteroids(int size, int move, int direction, int rotation) GreenfootSound split = new GreenfootSound("break.mp3") ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |