This site requires JavaScript, please enable it in your browser!
Greenfoot
Username
Password
Remember Me?
Sign Up, Lost Password
Activity
About
Documentation
Download
Discuss
Scenarios
Discussions
You need to login to take part
Current Discussions
how do i make an actor disappear when they hit
By Fallen_Bird, with 3 replies.
Last reply by rdFx, almost 3 years ago:
Fallen_Bird wrote...
in my book it saying to put a code but it's not working here is the code: //... if(canSee(Rocket.class)) { eat(Rocket.(class); //...
Typo here!? Should be eat(Rocket.class); I guess..
How to keep a variable even after restarting Greenfoot?
By Gerrit486, with 2 replies.
Last reply by danpost, almost 3 years ago:
rdFx wrote...
You could use static fields to keep track of which levels were unlocked before:
This will work during a single session, but will not work when going from one session to the next (scenario is closed and reopened -- or recompiled). For that, you will have to use a file or database to store the progress. A file is sufficient provided you do not upload the scenario onto a website. To work on a webpage, Greenfoot provides the UserInfo class to allow variables to have their changing values stored in a database.
Hello, can I get my account deleted?
By Shockal, with no replies.
Title.
Exception instantiating world class:java.lang.IllegalArgumentException
By LIU-25535, with 2 replies.
Last reply by LIU-25535, almost 3 years ago:
I have already finished it. Thanks a million. I really appreciate it.
Please help :)
By LoafofBrad, with 3 replies.
Last reply by danpost, almost 3 years ago:
Oops -- line 24 above should be: <Code Omitted>(missed the closing square bracket for the index of the array)
Very hard for a beginner!!
By Jpinkham, with 1 reply.
Replied to by danpost, almost 3 years ago:
Jpinkham wrote...
The game was working fine but when i tried to put timer then the game started to crash down. I removed the timer but still it shows error but doesn't show where the error is. I tried restarting it, now it wont even open and wont show Mainworld() sub class. Can anyone please help me with this?
You will either have to upload your scenario to this site with publish source code checkbox checked or show all your class codes here (using 'code' tags).
How can I put a delay between bullets?
By DavidZyy, with 1 reply.
Replied to by Spock47, almost 3 years ago:
First thing is to decide how long the delay between two bullets should be, e.g. "2 seconds". Since Greenfoot regularly calls the act method, the unit for the delay should be "number of calls to the act method" (/"cycles"). On normal speed, Greenfoot calls the act method approximately 60 times a second. 1. So, let's define a constant for the duration until the next bullet can be fired: <Code Omitted> 2. Next, an attribute is needed that stores the current state of the cooldown, e.g. storing the remaining time (in cycle
Is it possible that a scenario stops and restarts itself?
By lehrerfreund, with 6 replies.
Last reply by rdFx, almost 3 years ago:
I'm not sure but this might help you. You can always define methods in the World class that are callable via right click on the scenario screen. So in your case you might want to add a method "showTutorialText()" or "switchSound()" that is defined in your World class (needs to be public i guess) and is callable via right click (a drop down with all methods should be shown). This only works if you don't need to run your scenario as an app but it will work if the scenario is paused in greenfoot!
Stop all GreenfootSounds at once?
By lehrerfreund, with 7 replies.
Last reply by Spock47, almost 3 years ago:
lehrerfreund wrote...
There is one flaw: If a not registered sound is called (...) a FileNotFoundException is thrown by the create-method.
Good catch! :)
Check for mouse click without act()-method running
By lehrerfreund, with 8 replies.
Last reply by RcCookie, almost 3 years ago:
The other problem is that, because Greenfoot does not restart the JVM every time you press "Reset", threads will remain running until you restart Greenfoot. To fix this, we have to keep track of the actors that were created and stop threads of actors that are not on the active world. Putting it all together:
showing error in semicolon of stsement
By sashvanth, with 2 replies.
Last reply by sashvanth, almost 3 years ago:
ok
Check an offset relative to my rotation
By AbdulrazaqAS, with 2 replies.
Last reply by AbdulrazaqAS, almost 3 years ago:
danpost wrote...
AbdulrazaqAS wrote...
Hello, I want to always check what is in front of my actor before moving but i dont know how i will use the method getOneObjectAtOffset(int dx, int dy, Class<?> cls) or any other method to achieve that.
Use sine and cosine of rotation multipled by distance. Rotation will need to be converted to radians.
Thanks, it worked.
Error reading file when game is exported
By drhorriblejr, with 3 replies.
Last reply by danpost, almost 3 years ago:
drhorriblejr wrote...
That's just the name of the file without the extension. I currently only have one level named test so it makes the path "levels/test.txt," and that path exists in the greenfoot project directory locally
Seems like you have everything in order. Maybe your file operations are not what javascript would allow.
Throws an exception if not logged in
By AbdulrazaqAS, with 7 replies.
Last reply by AbdulrazaqAS, almost 3 years ago:
danpost wrote...
AbdulrazaqAS wrote...
I have uploaded the scenario, all the following classes are using UserInfo class; Area, FirstScreen, Board and Bomb.
Unfortunately, the
UserInfo
object may still be
null
even when storage is available. Therefore, after assigning the object to a variable using
getMyInfo
, check it for
null
before trying to work with the object (in each and every place you access it).
Thanks it works.
Not displaying User Image
By AbdulrazaqAS, with 5 replies.
Last reply by AbdulrazaqAS, almost 3 years ago:
Ok, thank you all.
34
35
36
37
38
39
40
X