![]() This is a good design because you can create several Key Actors with different assignments, i.e. If you look at this method at line 41, it calls the playSound method, passing in the sound class varilable you populated with the second parameter to the constructor. you constructed this Actor with "A"), so it looks for "A". If you then look at line 28, the if statement looks to see if key pressed is the value in the key class variable (i.e. Now, that constructing method, put's the string "A" into the class variable key and the sound file name into sound class varilable (lines 6 & 7). Basically, when you create a new Key, you do so by: Public Key(String keyName, String soundFile) ![]() Please refer to the Java tutorial page on Classes for information on class constructors and how they are used.Although I've not read the book, this is pretty straight forward java. Also, the 'addObject' method accepts an Actor and two ints as arguments (not just an actor - if that is what is returned by 'newEmoticon'). And line 50 has an unknown method 'newEmoticon' being called using a concatenated String value as an argument (which I doubt you want to do). That condition is accounted for in the 'for' statement on line 46. Lint 48 of the HomeworkWorld class is not needed. I think you want to save individual Strings in each of the Emoticon objects created, not arrays of Strings. Then, lines 37 and 38 are trying to set arrays to String values. * a dot, '.', before the file name suffix on line 55 of the Emoticon class * a constructor declaration statement between the field declarations on lines 18 and 19 and the constructor code, lines 36 through 39 of the Emoticon class * a semi-colon, ' ', at the end of line 36 of the Emoticon class * The y value can be either hard coded or calculatedĪddObject(newEmoticon(image + sound)) * Determine the x value using a mathematical calculation * Note: concatinate the ".png" for images and ".wav" for the sounds * It should use the method addObject( Actor object, int x, int y) to add new Emoticons to your world. add instance field to class GreenfootSound wind new GreenfootSound('wind. * It should loop 5 times (you can either hard code 5 or use code) To gain more control of the playing of a sound file, use the GreenfootSound constructor and methods. Create a new world with 400x100 cells with a cell size of 1x1 pixels. * Constructor for objects of class HomeworkWorld. * DO NOT INCLUDE THE FILE SUFFIX - add that through code later * Add two instance variables that are of type String * scenarios creating images and sounds together. * Write a description of class HomeworkWorld here. * Use the method aySound( filename ) to play the sound When the mouse is click on this object, play the sound. If you want to play a sound using a trigger, then look at the SoundObjectPlay () function, as PlaySound () requires an object to work. * 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 * Create two instance varaibles of type String * Write a description of class Emoticon here.Create 5 different images and sounds to run. Import greenfoot.* // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |