This site requires JavaScript, please enable it in your browser!
Greenfoot back
schetefan24
schetefan24 wrote ...

2013/5/9

not reseted variabels after pressing the "reset"-button

schetefan24 schetefan24

2013/5/9

#
For school we are currently programming in little groups games and our game is a Jump 'n' Run. But now there is a strange bug in the project. I can play the first run normally, but if I reset the World (just using the "reset" button below the world) the second run isn't working correctly. The objects are moving automaticly, if press "right" and have reached the right position. To do that I have a initialized a variabel to count, how far I already run. It can be, that this variable is not reseted by pressing the "reset" button. If i compile the project again, I can do a normal run,but after this it isn't working again. Has someone an idea, what else could be the matter or how I can fix my problem? (I also wrote a method that resets the variabel once in the first act, so it's probable, that the error has an other source... ) I don't know how to add a Greenfoot-project here, so I zipped it and you can download it here: https://docs.google.com/file/d/0B1IYv183t8YDTW1yMGpWQUlmbk0/edit?usp=sharing (just press "CTRL" + "S" to download the whole zip-file) Everything is written in german and you also may answer in german, I just wrote this entry in english, to be sure that everyone understands me :) If you have questions to the current code (because the notes are in german) just ask me. nearly everything of the programm runs from the world ("Springfield") and the main actor ("pieman") schetefan24
danpost danpost

2013/5/10

#
To upload the scenario onto the Greenfoot site, open the scenario in Greenfoot and click on the Share button near the top-right of the scenario window. A new window should appear already open to the 'Publish' tab. Fill in the appropriate information on the form window (minimum: title, username and password) and be sure to check the 'Publish source code' checkbox before clicking on the 'Share' button.
schetefan24 schetefan24

2013/5/10

#
thanks for the explanation, that was too easy :D it's now online: http://www.greenfoot.org/scenarios/8305
schetefan24 schetefan24

2013/5/10

#
I just looked over my code again and found the mistake, 2:00 AM is too late for finding bugs like this :D I forgot one variable in the constructor, it could only be changed back by compiling, because it's set to 0 at the declaration -.- it works now, but it's a little bit strange, that the declaration is not used again after reseting... now this topic and can be closed and deleted, if you want to say sth about my game itself you do it at the game now :) http://www.greenfoot.org/scenarios/8305 schetefan24
davmac davmac

2013/5/10

#
Is it a 'static' variable by any chance? static variables can't be reset using the reset button.
schetefan24 schetefan24

2013/5/10

#
right idea... it's static... in an earlier version I needed the variabel to be static, because I tried to set it from an actor class (it failed, now it's running on another way) thx, now I can clean up the code :D (I will have to hand it in, because it's a school project)
You need to login to post a reply.