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. These games may look a little bit crude, but with a little imagination, they can still be very fun.Import greenfoot.* // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) Upload the apk, using google drive, and download it on to your phone.Make a signed apk by going to the build menu in Android Studio.If you have done this correctly, you will see the assets in android studio.įinally you will make the Android package. Open the activity file being renamed in step 5, remove the comment in front the statement in method onCreate and assign the class object of your world class to the variableĭroidfootActivity.worldClass (DroidfootActivity.worldClass = SpaceInvadersWorld.class Ĭopy the folders images and sounds which contain the images and sounds of your Greenfoot scenario into the folder DFTemplate/src/main/assets. Please note that you will have to edit all java-files to define the corresponding package-statement as the first statement ( package ).Įliminate all errors in your java-files which can occur due to the differences between the original and the Android Greenfoot class library (see chapter 2). package="" )Ĭopy the java-files of your Greenfoot scenario into the package being renamed in step 4. Open the file AndroidManifest.xml and rename the package-attribute (second line) corresponding to the renaming in step 4 (e.g. Rename the file/class DFTemplateActivity in folder src in the package being renamed in step 4 (bspw. Open the file strings.xml in folder DFTemplate/src/main/res/values and replace the name DFTemplate by the name of your scenario (e.g.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |