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
Keep Object in New World
By HEISENBERG, with 6 replies.
Last reply by danpost, over 6 years ago:
HEISENBERG wrote...
Well for some reason my player gets stuck at level 2 as the counter gets reset every time
Use the current level to determine what level to proceed to. Something like the following to replace all player codes above:
How to remove object after it reach edge and remove object if it hit another object?
By dROS, with 2 replies.
Last reply by dROS, over 6 years ago:
Thank you so much for your help
How do I access an object from another class?
By NB111, with 3 replies.
Last reply by danpost, over 6 years ago:
Nosson1459 wrote...
Also just by way of suggestion you can cut your code by at least half if you use an Array, and For loops to place them in the world. like this: <Code Omitted>to instantiate them use a For loop like this: << Code Omitted >> to add them in to the world use this loop << Code Omitted >>
The quoted line of code should be: <Code Omitted>and I would have done the rest with:
Need help with making an inventory with Singleton pattern and ArrayList
By XardasTheSilent, with 11 replies.
Last reply by XardasTheSilent, over 6 years ago:
Thank you for the example. I modified my inventory a little and know I have this:
java.lang.NullPointerException NEED HELP!
By Vitalizera, with 3 replies.
Last reply by danpost, over 6 years ago:
Remove the first word from line 21. You do not want to declare a new variable there. You want to refer to the field declared on line 3.
Showing Text in a Game
By Haylaylo11, with 6 replies.
Last reply by Haylaylo11, over 6 years ago:
Nevermind, I just figured it out. I feel really dumb, but thanks for your help!
Grabbing Weapons In A Top Down Shooter
By W_JL, with 1 reply.
Replied to by danpost, over 6 years ago:
W_JL wrote...
I want to make the weapon dissapear after I grab (or should i say touched) it and make it appear on my character. I used if touching and then transparancy to 0 but with that code I can't make the weapon follow my character around because if I touched it. It will dissapear.
True that you cannot have it both disappear and appear at the same time. So ... why make it disappear at all?
Scrolling world with mouse
By mattnorth, with 1 reply.
Replied to by danpost, over 6 years ago:
mattnorth wrote...
I am making a game similar to Agar.io and I am having issues with my actor following the mouse in the scrolling world. Anyone know how do scroll using the mouse?
Program the actor to follow the mouse without regards to the scrolling. Then, scroll the world depending on the actor's position.
Transfering Variables from Actor to World
By PhoenyxProgramming, with 2 replies.
Last reply by danpost, over 6 years ago:
PhoenyxProgramming wrote...
I'm now trying to make the chance of Food Spawning randomly, which I have coded in the MyWorld class, dependant on the 'Score' variable from the Ant class (or set global Variables in the World class which can be changed by Actor classes). << Code Omitted >>
An easy way is just to keep a reference to the
AntPlayer
object in your
MyWorld
world:
Exporting standalone to Raspberry pi (Raspbian)
By Higgins1904, with no replies.
Hi, I have done a simple Greenfoot project at my Win 10 computer, runs fine in the Greenfoot GUI version 3.6.0. Now I want to export it and run it at my Raspberry pi 4 (Raspbian) that has the Java version 11.0.5. I read at the export info page here that one need to tinker with the command line arguments when executing the exported jar-file. Anyone that knows what needs to be done? I try to run it with the following command line: java -jar /home/pi/test.jar I get an error message saying that the class greenfoot.export.GreenfootScenarioApplication is missing or could not be loaded. The file is there in the jar file, at the path greenfoot.export, I can see that when inspecting the contents of the package. Both my Pi and my Win 10 computer runs Java 11
Exercise 9.70 add asteroids using generic type list<>
By dROS, with 2 replies.
Last reply by dROS, over 6 years ago:
Thank you so much for your help. you are awesome
Greenfoot.mouseClicked doesn't seem to be working
By NB111, with 2 replies.
Last reply by NB111, over 6 years ago:
Super_Hippo wrote...
1. The act method should not have any arguments. 2. The mouseClicked method requires an Actor object. Not a list. <Code Omitted>
Thanks
Setting Images
By TylerBlair, with 3 replies.
Last reply by danpost, over 6 years ago:
TylerBlair wrote...
How should I change it so the image displays on top of the black background?
To display it "on top", you would use an actor. To display it "on", draw the
directions
image onto the background of the world.
Pause Code of one Object
By insurqassable, with 1 reply.
Replied to by danpost, over 6 years ago:
insurqassable wrote...
<< Code Omitted >> I want to have a little bit of time between the image of the lock getting changed and the lock getting deleted, so you can actually see the opened Lock.
Add an
int
timer field to the
KeyLock
class. Set it to some positive value (30-60 maybe) when opened. Use
act
to count down the timer and upon reaching zero, remove the actor.
Hey, How do i use generic class type List<>
By dROS, with 1 reply.
Replied to by danpost, over 6 years ago:
dROS wrote...
How do i use generic class type List<> to calculate how many asteroids are left in the world background and add new asteroids when all have been cleared away. new ones appear, one more every time.
Just use: <Code Omitted>in an
act
method in your
Space
class.
159
160
161
162
163
164
165
X