The problem was that I forgot to add fall() to the act class of my actor itself - the jumping and falling is now working, but the actor gets nevertheless teleportet, when he hits a block/obstacle. Sep 2022 1 Hallo, wir haben aktuell in der Schule Informatik und haben als Aufgabe bekommen herauszufinden, ob es möglich ist, hier einen Sound einzubinden. If (onGround & Greenfoot.isKeyDown("w")) vSpeed = -jumpStrength Int dx = 0 //determine direction to move (left=-1, right=1 and none=0) > // code unknown for your project (you decide) Working movement code: setLocation ( getX() - speed, getY() ) But what makes me suprise: sometimes the sounds work like I want them to, but also sometimes they dont. I got the sounds from YouTube (free YouTube to MP3 converter). Ein Objekt der Klasse GreenfootSound kann Klänge aus einer Datei laden. If (onGround & Greenfoot.isKeyDown("w")) jump() Ill try to use audacity (I already got the programm). Mit Hilfe dieser Klasse kann die Audioausgabe in Greenfoot realisiert werden. ![]() Working movement code: setLocation ( getX() + speed, getY() ) Private int jumpStrength = 20 //Sprungstärke Private int FallAcceleration = 2 //Fallbeschleunigung Private int vSpeed = 0 //speed (Fallend/falling) Private int speed = 3 //speed (seitlich/sideways) First you create a new sound like this: GreenfootSound sound new GreenfootSound ('filename') // the filename is the same as the one you would use in the playSound method You should create this sound as a global one (at the top of your code). * the 'Act' or 'Run' button gets pressed in the environment. If you want the sound to stop you have to use the class GreenfootSound. * Act - do whatever the PeterP wants to do. Sound files must be placed the sounds folder of your Greenfoot project to be used in the game. ![]() ![]() * Write a description of class Ojekte here. 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 |