![]() ![]() I am not sure what you were trying to do with line 1 (or why you wanted to create a method here). Use of started () and stopped () method in World to avoid music that plays forever. 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. Teaches: Use of GreenfootSound API to create and optimize music and sound effects. ![]() The argument 'filename' is not used in the method anywhere - so there is no need to have the argument at all. Method names should give some indication as to what the method does the first word in the name should be a verb. Your expression to the right of the equal sign on line 3 looks good. 'variableName' can be any name that follows the rules given at the bottom of this page. To stop the game you just need to call Greenfoot. You could also remove all the objects in the world before doing this or stop the execution of the game. 'variableType' can be any primitive type (int, float, boolean, long, byte, char, etc.) or a class name (String, Color, Font, Actor, World, etc.). If you just want a game over screen you just need a new class with an image which you add to the world when your character dies. If you have ever found adding sound into Greenfoot difficult then this short video will give you the confidence you need. VariableType variableName = expression_or_value I know how to make sound stop before it changes to a different world but I need to be able to change it after because I want the music between the first three levels to be continuous but the Boss level needs to change sound and I dont want the normal level sound playing over it. If the sound is currently looping, it will finish the current loop and stop. 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): If it is playing already, it will do nothing.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |