I am not sure what you were trying to do with line 1 (or why you wanted to create a method here). If you got 'GreenfootSound( filename)' from the API, then you were looking at the constructor signature and you used it properly at the end of line 3. The argument 'filename' is not used in the method anywhere - so there is no need to have the argument at all. You need to keep a reference of the one that is playing and stop it: // instance reference field (inside class but outside method) private GreenfootSound sound // line 23 sound new GreenfootSound('Fetty Wap - Trap Queen.mp3') // line 33. Method names should give some indication as to what the method does the first word in the name should be a verb. This is not the instance that is already playing - so stopping it will not stop the sound from playing. Your expression to the right of the equal sign on line 3 looks good. the issue is that as it is constantly checking if my mouse is there, it is constantly playing the sound while the mouse is there as opposed to only playing it once. as you mouse of the options, a sound is played. 'variableName' can be any name that follows the rules given at the bottom of this page. So i am programming a screen in which there are three options to select. But, it does know about an 'isTouching' method for an Actor object. Nor does it know of any 'Touching' method (even if 'is' referred to an Actor object). 'variableType' can be any primitive type (int, float, boolean, long, byte, char, etc.) or a class name (String, Color, Font, Actor, World, etc.). The compiler does not know what object 'is' refers to. VariableType variableName = expression_or_value Neither line 3 nor line 4 could possibly compile without an exception being thrown.Ī variable is assigned a value like as in the following (in pseudo-code): Nothing stops you from borrowing any of the sounds provided with the various tutorials on the Greenfoot website.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |