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 to remove the object after 3 second
By mariq_rasyid29, with 2 replies.
Last reply by mariq_rasyid29, almost 5 years ago:
thx again sir
climbing a ladder
By Genota, with 3 replies.
Last reply by danpost, almost 5 years ago:
At line 118, insert the following: <Code Omitted>
how only in the world can play the backsound?
By mariq_rasyid29, with 9 replies.
Last reply by mariq_rasyid29, almost 5 years ago:
wow, thx sir
Is there a way to count times the "isTouching" function is repeated?
By ThiagoPorto, with 4 replies.
Last reply by danpost, almost 5 years ago:
ThiagoPorto wrote...
Where I add this
int
?
Anywhere in the class
not
in a sub-block (method or constructor).
How to use Lists
By Znarf, with 1 reply.
Replied to by danpost, almost 5 years ago:
You could: <Code Omitted>or begin line 2 with: <Code Omitted>or, more simply: <Code Omitted>
How to refer to a variable in the World from an Actor
By Znarf, with 5 replies.
Last reply by Gbasire, almost 5 years ago:
danpost wrote...
Gbasire wrote...
write this in your Actor class : <Code Omitted>
SnakeX
and
SnakeY
will not be found. Those variables were local to the constructor.
or alternatively if you have only one snake in the World write this in your Actor class : <Code Omitted>
Unless
snakeX
and
snakeY
were declared variables in the cla
How to start method as soon as Key is clicked
By Znarf, with 3 replies.
Last reply by danpost, almost 5 years ago:
Oh, you are saying that your scenario is running at a very slow frame rate. Run at normal speed, use a int timer to regulate moving and track direction input with another int field.
How to check if there's an object at a specific location
By Znarf, with 5 replies.
Last reply by danpost, almost 5 years ago:
danpost wrote...
The
World
class has a
getObjectsAt(int, int, java.lang.Class)
method.
The 2nd word here says it all. Use:
getWorld().getObjectsAt( ... )
Button Sound Array
By ronald, with 55 replies.
Last reply by ronald, almost 5 years ago:
I put it in the Greenfoot scenario the progress bars stop before the end while on the IDE they go to the end
Is there a way to convert void to boolean?
By xsolvite, with 4 replies.
Last reply by RcCookie, almost 5 years ago:
turnTowards(int, int) cannot return something, because what should it? There are multiple things imaginable here. For example, which is what I think you thought of, return weather the object was looking at that location before anyways. But it could also return the angle in degrees it has rotated to face that object, or the new rotation after turned towards that location, or weather the locaiton given was actually valid to look at and not the objects location itself, or... You see, it really did not make any sence if you could convert void methods so that they return a value. If you want that
Moving platform up and down
By Genota, with 7 replies.
Last reply by danpost, almost 5 years ago:
Genota wrote...
Like an elevator. So if the platform is going up, the player should be go up too (pushed). In my world, it will never happen, that the player get pushed into another object/ground or anything else, because of the design of the map.
Okay:
How do you bounce a bullet off of a wall in the opposite direction?
By xsolvite, with 3 replies.
Last reply by danpost, almost 5 years ago:
Collision checking should come AFTER any change in position (or rotation) -- that is, any change not dictated by collision to begin with. There are two actions that should be performed when a collision occurs: moving (or rotating) off the object collided with and turning. The first of these is often missed by young coders.
Help with NullPointer on exercise 9.70
By Sfven, with 3 replies.
Last reply by Sfven, almost 5 years ago:
In
act
method of
Space
class, you can use: <Code Omitted> Thank you Dan, that was the code I was missing. I should also mention, my professor also said that we were not allowed to modify the
act
method, so I replaced line 100 of the
Asteroid
class with the if statement you posted. It looks like this:
Changing color of text
By BlueHand, with 1 reply.
Replied to by danpost, almost 5 years ago:
You will need to have the
Instructions
object retain the message for later use (add a
String
field and assign
message
to it) and then add a
setColor
method to the class that acquires a color (via parameter argument) and creates and sets an appropriately colored new image.
stop background music when switching world
By Genota, with 1 reply.
Replied to by Super_Hippo, almost 5 years ago:
To stop a sound, you need a reference to it. After you changed to the new world in line 34 of the Title_Screen class, you won’t have any further chance to get a reference to the sound object from the newly created world, so it will run forever. A few alternatives you could go for: 1) stop the sound before changing the world 2) pass a reference when you create the new world 3) make the sound a class variable (static) instead of an object variable to access it from anywhere more easily
85
86
87
88
89
90
91
X