![]() ![]() 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. 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. private GreenfootSound Title new GreenfootSound. void: setVolume(int level) Set the current volume of the sound between 0 (off) and 100 (loudest. I am also not sure how to properly use the isPlaying() boolean method within if statements in order to regulate when the sound plays. 'variableName' can be any name that follows the rules given at the bottom of this page. i just cant quite seem to get this working, i have a title and 3 levels and i have 4 tracks, one for each, i just cant seem to get them working, when i go to the next level, the previouse level music has to end and the new ones begin, here are my tracks. Each music piece that is started in the started () method should be stopped in the stopped () method. Ive successfully gotten the game to play the sound and play it on loop, but when Im asking the sound to stop playing, it will not. 'variableType' can be any primitive type (int, float, boolean, long, byte, char, etc.) or a class name (String, Color, Font, Actor, World, etc.). VariableType variableName = expression_or_value YouTube 0:00 / 1:23 If you have ever found adding sound into Greenfoot difficult then this short video will give you the confidence you need. 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(Greenfoot.That could not possibly compile. If(Greenfoot.isKeyDown("up") & jumping = false) * Act - do whatever the Player wants to do. Private GreenfootImage run4l = new GreenfootImage("run4l.png") ![]() Private GreenfootImage run3l = new GreenfootImage("run3l.png") Private GreenfootImage run2l = new GreenfootImage("run2l.png") Private GreenfootImage run1l = new GreenfootImage("run1l.png") Private GreenfootImage run4r = new GreenfootImage("run4r.png") Private GreenfootImage run3r = new GreenfootImage("run3r.png") Private GreenfootImage run2r = new GreenfootImage("run2r.png") Private GreenfootImage run1r = new GreenfootImage("run1r.png") ![]() Private int shootingCounter = 20 // Delay shooting Private int direction = 1 // 1 = right and -1 = left * Write a description of class Player here. * the 'Act' or 'Run' button gets pressed in the environment.Īctor walls = getOneIntersectingObject(Platform.class) Īctor actor = getOneObjectAtOffset(0,0, clss) Īnd here is the current Player code: import greenfoot.* // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) * Act - do whatever the ShootingManager wants to do. Public class ShootingManager extends Actor thanks:) and i forgot to crop the starting bit out :D. * Write a description of class ShootingManager here. A new version of this scenario was uploaded on Mon Aug 06 13:46: fix a sound ploblem. instead of: aySound ('sound. This is our "ShootingManager" class from today: import greenfoot.* // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) To stop it or pause it you have to use the class GreenfootSound. If you create a GreenfootSound object, you can use the GreenfootSound class methods to control the playing/stopping of the sound. Today we are adding "shooting" to our game. 4 When using the Greenfoot class 'playSound' method, you do not have an object reference to the GreenfootSound object to control it. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |