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 find if a certain class is located at a certain location?
By nubnt_, with 1 reply.
Replied to by danpost, 10 months ago:
nubnt_ wrote...
How do I find if a certain class is located at a certain location?
From within your subclass of
World
, you can use the
getObjectsAt(int x, int y, Class clss)
method. This will return a list of actors of given type at that location. If you don't need the actor itself, just checking if the list is empty is enough: <Code Omitted>otherwise:
Help: Why can't I just get the X position of the mouse
By nubnt_, with 2 replies.
Last reply by nubnt_, 10 months ago:
Thanks. (sorry for the late reply)
Objects Generating In front of Existing Objects
By Gael, with 2 replies.
Last reply by Gael, 10 months ago:
Thank you very much! it worked great and had a better effect than I thought
Clicking anywhere on the screen to start code using Greenfoot.mouseClicked
By charmanderr, with 1 reply.
Replied to by danpost, 11 months ago:
charmanderr wrote...
How do I use if(Greenfoot.mouseClicked(para)) to have the user start the game when they click anywhere on the screen? This is for an assignment, and the user is prompted to start the game. I've set the Background to an image, and put (this) into the parameters, and then called a method that I already wrote out. << Code Omitted >>
The code you are showing is only executed when that particular world is created. It does not run when you click on the "
Step
" or "
Run
" buttons. The code (lines 3 through 6) needs to be in the
act
method or a method
Help with programming error
By ThomasGaldieri, with 1 reply.
Replied to by danpost, 11 months ago:
After copying all codes into classes in greenfoot, it compiled for me. I did remove some codes, however -- only those related to sounds and images (because I did not have the required files for them. Classes with syntax errors should show with diagonal red stripes through the class icon and lines containing errors should be marked by red at the beginning of the lines. Also, the error within the line may be underlined, however, some syntax errors have these underlines show at places not exactly where the error actually is.
Respawn character
By CowboyIggy, with 1 reply.
Replied to by danpost, 11 months ago:
CowboyIggy wrote...
I want to make a character respawn after 5 seconds dead. << Code Omitted >> I'm using this code, is there a way to make the character be added in the world 5 seconds after been removed?
One simple way to handle it is by creating a new type of
Actor
for the dead ones:
Actor remembering what world they are in?
By trulydevious, with 4 replies.
Last reply by danpost, 11 months ago:
Since it was part of the assignment, you will need to include the field: (see line 6):
A use for stand alone jar exportation
By bakl, with no replies.
In this
post
it was asked why the stand alone jar generation is useful. The big use I have for it is to be able to write code using the Greenfoot "library" not in Greenfoot. By using the
running on Netbeans
tutorial and using version 3.8.1 I was able to develop in IntelliJ Idea which I prefer to the built in editor.
how to create a Greenfoot project in Visual Studio Code
By won0c, with 2 replies.
Last reply by Fliedermeyer, 11 months ago:
Look at this https://github.com/LeoTuet/greenfoot-maven-starter
Getting an actor's coordinates in world class
By tiny, with 1 reply.
Replied to by danpost, 11 months ago:
tiny wrote...
So I have an actor moving and I want to get the x and y coordinates of that actor in the world class so I can store it in a variable inside the world class
By keeping a reference to that actor in your
World
subclass, you can easily use something like the following: <Code Omitted>Line 1 assigns an object of type
Player
to the field named "
player
". Actually, a memory address of the "player"'s information is stored and held by the fi
Create a splash screen
By AdrianoFreitas, with 2 replies.
Last reply by AdrianoFreitas, 11 months ago:
Good evening danpost, thank you very much, I looked at your code example today, this week I will continue the game project. If I have any questions I will ask you.
Help: getBackground() to remove images in world?
By Connorg1215, with 7 replies.
Last reply by danpost, 11 months ago:
The (same) problem is with lines 47, 49 and 54. They do not retain the objects in the fields provided on line 8. The values for those fields remains
null
and the checks for clicks will fail on these, or, at least, not work as you intended. To retain the buttons in the fields, you must not create a new variable (which those lines do). Look back at what I gave to see how they get retained. Also, note that the field names I gave are not (at least case-wise) the same as the class name. This helps for readability of your code (letting you know it is a variable name, not a class name).
Setting location after switching worlds
By NeedyJellyfish, with 4 replies.
Last reply by NeedyJellyfish, 11 months ago:
It worked!!!!! Thank you soooooo much
Need help with javaruntimeexception
By endplasticbottles, with 2 replies.
Last reply by endplasticbottles, about 1 year ago:
Thanks that worked!
Character getting inside platforms
By CowboyIggy, with 1 reply.
Replied to by danpost, about 1 year ago:
CowboyIggy wrote...
I did a moving platform: << Code Omitted >> But I'm having an issue when my character walks on it, when it moves horizontally the char isn't moved together with the platform but that's ok since the character can move on its on. The real problem is when I try to move on a platform that is moving vertically cause my character does not move within the movement of the platform so when the platform goes up my character stays the same place and then get inside the block of platform. My character code: << Code Omitted >>
When a collision occurs between the moving pla
4
5
6
7
8
9
10
X