3/9/2024 0 Comments Greenfoot sound intermittent![]() Somewhere in between setVolume() and getVolume() there is a logarithmic function. So setVolume(86) sets the volume to… Refer to table above… 96.Īhhhhhhhhh… We get stuck. Inside the setVolume() method we call getVolume() which returns 96 then we decrease that by 10 for a total of 86. Then finally, if we click again we call setVolume(getVolume()-10). So setVolume(87) sets the volume to… Refer to table above… 96. Inside the setVolume() method we call getVolume() which returns 97 then we decrease that by 10 for a total of 87. Then if we click again we call setVolume(getVolume()-10). So setVolume(90) sets the volume to… Refer to table above… 97. Inside the setVolume() method we call getVolume() which returns 100 then we decrease that by 10 for a total of 90. So what was happening with my original code: setVolume(getVolume()-10)įirst we click the volumeDown button. He suggests graphing the output and see if it makes any sense. Discouraged and delirious (its about 3am at this point) I ask my roommate to take a look. When I call setVolume(50), getVolume() returns 84? What is going on here? I scour my code to find where this could be happening but turn up nothing. Infuriating, this seems to make no sense. This steps through every possible parameter that could be sent to the setVolume() method and outputs it to the console. (index + " " + music.getVolume() + "\n") So I added this to run once and output what the value does as you call the setVolume() method:įor(int index = 0 index <= 100 index++) I spent quite a long time trying to figure it out, seemed to be making no head way. Now I want to talk a little bit about my adventure identifying the problem. I clicked it again, this time no change to the volume. This time it only decreased by one to 96, bizarre! I prayed to the machine spirit this time hoping to get in his good graces. I checked the code, Its coded in there to decrease by ten, so I clicked it again. So when I clicked the volume down button you should expect the getVolume() method to return 90, however this post wouldn’t exist if it did, it only decreased by three to 97. This code was producing some unexpected results. VolumeDown class is similar just decrements the volume by 10 Im at a loss here, when I send getVolume to output it gives me some funky stuff.Īny help would be greatly appreciated, Thanks. tLocation(volumeBar.getX(), volumeBar.getY() - 18) VolumeBar.getImage().scale(volumeBar.getImage().getWidth(),volumeBar.getImage().getHeight() + 36) If(Greenfoot.mouseClicked(this) & volumeBar.getImage().getHeight() < 360) Public VolumeUpButton(VolumeBar volumeBar, GreenfootSound music) * the 'Act' or 'Run' button gets pressed in the environment. * Act - do whatever the VolumeUp wants to do. Public class VolumeUpButton extends Button * Write a description of class VolumeUp 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 |