![]() ![]() MyWorld.addObject(gameover, MyWorld.getHeight()/2, MyWorld. ![]() Can it be that all the sounds are playing at the same time when the game ends? Here's the code Also you may want to fix line 47 if you want random number from -5 to 5 it should be: int newX Greenfoot. Greenfoot aims to motivate learners quickly by providing easy access to animated graphics, sound and interaction. All standard Java libraries can be used as well, and sophisticated functionality can be achieved. Just remove the eat method (and the call to it from the act method) and add the command to play the slurp in the lookforcrab method. Greenfoot offers API methods for a range of common tasks, such as animation, sound, randomisation, and image manipulation. Dont forget to turn your speakers on (or. You have aysound ('fallenthing.wav'), It should be aySound ('fallenthing.wav') (Note that the 'S' in sound should be capitalized). You are calling lookforcrab which will eat the worm without sound then, you are calling eat which would (if a crab was left to eat) make a sound when eating. We can make that sound play every time the crab eats a worm by adding a single line to our crab class that calls aySound after we remove a worm from the world: Give that a try. ![]() Like in my previous discussion I am trying to make a settings menu in my Settings world where it has options such as a button that mutes sound effects from actors in my PlayWorld. Find information on how to change the interface language in Greenfoot, and get other translated materials. Greenfoot has been translated into many different languages. The final object to be collected plays but it doesn't sound right. The scenario comes with a sound ready for you to use, named 'eating.wav'. My programming teacher doesnt really do a whole lot in terms of the sound aspect.) danpost. Hi all, Id thought that I would create another discussion in case there are people who also have the same problem as me. For 32-bit support, use Greenfoot 3.5.4 from our old versions page. The sound cannot be played several times simultaneously, but can be played several times sequentially. Public boolean onWall() // test to see if the man class is on the wall classĪctor Wall = getOneObjectAtOffset( 0, 0, Wall.class) Īctor Door = getOneObjectAtOffset( 0, 0, Door.I made a simple mistake and all but one sound is playing. Greenfoot wurde ja quasi dafür gemacht, die Objektorientierung zu vermitteln. A GreenfootSound loads the audio from a file. SetLocation(getX(),getY()+1) // move downĪctor Fire = getOneObjectAtOffset( 0, 0, Fire.class) SetLocation(getX()+1,getY()) // move Right SetLocation(getX()-1,getY()) // get loaction of x and y, then move -1 on x move Left If the crab is still at the edge when the. The Crab object will then always keep a reference to the one GreenfootSound object created (instead of creating multiple GreenfootSound object and having them play over the top of each other). A GreenfootSound loads the audio from a file. First, move line 16 to outside the method. Do I add that in the world as its own method or do I just put it in Thanks though :) danpost. * the 'Act' or 'Run' button gets pressed in the environment.ĬheckKeyPress() // call this method to work Method Detail: Constr Method SEARCH: Package greenfoot Class GreenfootSound greenfoot.GreenfootSound public class GreenfootSoundextends Object Represents audio that can be played in Greenfoot. Like this: GreenfootSound backgroundMusic new GreenfootSound('your sound file path') ayLoop() JesseOrange. Import greenfoot.* // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) Is there a way to add a sound based on an object class that you land on? and that it will only play every 5 seconds ? so far I got it to play when I'm on the object but it plays so fast.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |