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
Getting white screen and no console errors.
By jlau, with 1 reply.
Replied to by nccb, 10 months ago:
From poking it with the Javascript debugger, it seems that the world is actually loading up, but something is going wrong. It seems that the world remains GameWorld after initialisation. I suspect the problem may be that in the constructor of GameWorld, you call Greenfoot.setWorld() to change the world. But Greenfoot's default behaviour after constructing GameWorld is to call setWorld() with the just-constructed GameWorld, which happens after you have called it, so your change of world is ignored. As it happens, the Greenfoot desktop version has some code to guard against exactly this scen
Publishing
By karthigakumar, with 3 replies.
Last reply by danpost, 10 months ago:
karthigakumar wrote...
But I was found an error. Unknown host. How to solve it?
It could just be something temporary. Try it again. If the hosting error continues, see if a greenfoot team member can help you.
No suitable Java JDKs were found
By zonks, with 2 replies.
Last reply by zonks, 11 months ago:
That solved it! Thanks so much for your help. Navigating to the jdk folder in the Greenfoot directory worked.
UML from Greenfoot code?
By kaese340, with 1 reply.
Replied to by nccb, 11 months ago:
This
Stack Overflow page
has some suggestions for tools to do this. If you just want something basic then you can use our BlueJ tool to show a diagram. Make a new BlueJ project somewhere, close BlueJ then copy in all your Greenfoot classes and load BlueJ again. They won't compile because it won't find the Greenfoot classes, but it should at least show all the links between the classes in terms of inheritance and which class uses which.
Getting Exception instantiating world class:java.lang.IllegalArgumentException
By jlau, with 2 replies.
Last reply by danpost, 11 months ago:
jlau wrote...
Hi, I am getting Exception instantiating world class:java.lang.IllegalArgumentException - null on my scenario << Link Omitted >> Please help as I am not sure why
I believe the problem is that you left all the
System.out.println(...)
statements in your code when you uploaded it. Try removing them first (or comment those lines out of the code).
Points System
By Kookaburra737, with 1 reply.
Replied to by danpost, 11 months ago:
Kookaburra737 wrote...
I can't figure out how to Display the Heat/score, I read the notes in the displaying values tutorial but I'm having trouble understanding the concept.
There are only two ways to display anything in your world using greenfoot. One is changing the background image of the
World
itself (not recommended) and the other is by using the image of an
Actor
type object. The
Actor
object will need to be retained in an
Object
reference variable -- in a field, for example: <Code Omitted>Have it added into the world when
Moving Car
By hamzanius, with 1 reply.
Replied to by Kookaburra737, 11 months ago:
Hey! Try this: <Code Omitted>
Making A Method
By Kookaburra737, with 2 replies.
Last reply by Kookaburra737, 11 months ago:
Thank you so much!
java.lang.NullPointerException
By equopan, with 5 replies.
Last reply by danpost, 11 months ago:
equopan wrote...
I inspected the player and waffe is for some reason null. So there has to be a problem with the code at some point
You show this code:
Need Help With Pacman in clara world
By IcyCake242, with 1 reply.
Replied to by IcyCake242, 11 months ago:
This is what I have written so far
How to change background while running a loop
By TillaB13, with 9 replies.
Last reply by TillaB13, 11 months ago:
Thank you for the help, but I figured it out. I needed to break out of the loop and let the lava() method run in the act method. I LOVE YOU DANPOST THANK YOU!!!!!!!!!!!!!!!!!!!!!!!!!!
Recipe list
By ThieTime, with 1 reply.
Replied to by danpost, 11 months ago:
ThieTime wrote...
Hello, how can you create a recipe list when you press a specific keyboard key (without changing the world)
You want to create an object, yeah, an
Object
, a
RecipeList
object to put in the current world. Is that correct?
Help make gravity.
By Mr_Potato, with 9 replies.
Last reply by danpost, 11 months ago:
Mr_Potato wrote...
nope. I keep having the same problem. after a few bounces it just changes a lot.
I think your problem is that you need the change in motion of the ball to be smaller than a single pixel, which impairs on the smoothness of the motion. Solution is to use
float
s or
double
s to track the current location of the actor. Cast the values back to
int
s when setting location.
Collision problem in a platformer game
By Parrot279, with no replies.
Hello, I'm new in programming in greenfoot and I've encountered a problem when coding the collision method. When meeting an obstacle, my actor only phases through the upper part of the obstacle. These are my methods used to detect obstacles, respectively if the actor is on the ground: public void detectObstacole() { int dx = 0; int dy = 0; // checking for collision on the right side while (getOneObjectAtOffset(getImage().getWidth() / 2 + 1 + dx, 0, Platobstacole.class) != null) { dx--; } // checking for collision on the left side while (getOneObjectAtOffset(-getImage().getWidth() / 2 - 1 + dx, 0, Platobstacole.class) != null) { dx++; } // checking for collision on the top side while (getOneObjectAtOffset(0, -getImage().getHeight() / 2 - 1 + dy, Platobstacole.class) != null) { dy++; } // adjusting the position setLocation(getX() + dx, getY() + dy); } public boolean pePamant() { //checking whether the actor is on ground int x = getX(); int y = getY(); // checking for collision at current position if (isTouching(Platforme.class)) { return true; } setLocation(x, y + vitezaVerticala);// checking for collision at next position boolean onGround = false; if (isTouching(Platforme.class)) { onGround = true; } setLocation(x, y); // returns to former position return onGround; } As a note, the "Platforme" (which only includes platforms) class is a subclass of "Platobstacole" (which includes both platforms and obstacles).
How to add a loop background sound that goes in multiple levels and stops when the character dies.
By I3litz, with 2 replies.
Last reply by I3litz, 11 months ago:
Thank you im gonna try it out.
7
8
9
10
11
12
13
X