Use the code link below the Post a reply box to insert your code. Find the sounds folder and open it (it should be there and it should be empty). We will need to see how you set up the sounds and how you are trying to switch between them. When the mouse is click on this object, play the sound. Find the folder for the project you are working on and open it. * the 'Act' or 'Run' button gets pressed in the environment. * Act - do whatever the Emoticon wants to do. Use the method setImage( filename ) to set the image.Įmoticon emoticon = new Emoticon(image ,sound ) set the instance variable sound to the value passed by the corresponding parameter set the instance variable image to the value passed by the corresponding parameter Sounds =new String("hello","happy","crying","ohno","raspberry") ĪddObject(new Emoticon(images, sound ), 70*(i+1), 50) Images =new String("smiley1", "smiley2", "smile圓", "smiley4", "smiley5") If you're 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). * The y value can be either hard coded or calculated 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 it's just decoration). Mit Hilfe dieser Klasse kann die Audioausgabe in Greenfoot realisiert werden. * Determine the x value using a mathematical calculation Find information on how to change the interface language in Greenfoot, and get other translated materials. Greenfoot has been translated into many different languages. * Note: concatinate the ".png" for images and ".wav" for the sounds You will probably need to use the following: for (int i 0 i < Greenfoot.getRandomNumber (MAXACTORS + 1 - MINACTORS) + MINACTORS i++) With MAXACTORS and MINACTORS being the maximum and minimum numbers of those actors allowed to spawn at one time. For 32-bit support, use Greenfoot 3.5.4 from our old versions page. * It should use the method addObject( Actor object, int x, int y) to add new Emoticons to your world. * It should loop 5 times (you can either hard code 5 or use code) Create a new world with 400x100 cells with a cell size of 1x1 pixels. * Constructor for objects of class HomeworkWorld. * Create two instance varaibles of type String * Write a description of class Emoticon here. Greenfoot Guide 5 - Play Sounds CSNewbs 303 subscribers Subscribe Subscribed L i k e Share 1.3K views 2 years ago Greenfoot Guide How to play an audio file in Greenfoot. The sound cannot be played several times simultaneously, but can be played several times sequentially. 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.Import greenfoot.* // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) A GreenfootSound loads the audio from a file. It seems a bit redundant to have two arrays with exactly the same data. First, use the most recent version of Greenfoot (2.2.1), if youre not already. But what makes me suprise: sometimes the sounds work like I want them to, but also sometimes they dont. I got the sounds from YouTube (free YouTube to MP3 converter). But, the above should get your fields (which I renamed to more properly fit what they represent) and their references set up properly. If you want the sound to stop you have to use the class GreenfootSound. Ill try to use audacity (I already got the programm). 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. Where would depend on when you wanted it to start. 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. Public PlayMusicButton(String soundFiles, String songNames, Color colors) Public class PlayMusicButton extends Actor
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |