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
Creating a Game
By Lolboy123, with 1 reply.
Replied to by danpost, almost 1 year ago:
Lolboy123 wrote...
I want to have a bullet delay for the Shooter but I'm not sure how to code it << Codes Omitted >>
Just add an
int
shot delay timer to the
Shooter
class: <Code Omitted>
Stop Either Method
By Mzarifin58, with 4 replies.
Last reply by danpost, almost 1 year ago:
Mzarifin58 wrote...
I have try your program in my program, buat it doesnt work
Please show attempted code (entire class please).
So many errors
By Edit, with 4 replies.
Last reply by Edit, about 1 year ago:
I have fixed the issue. If you call addObject from a TimerTask class (java.util.Timer), then Greenfoot has a chance of giving an error when that Actor is being removed along with other ones. The only way to avoid the errors is to stop using the java.util.Timer. Greenfoot is not thread safe it seems
Accessing different Levels from a main Menu:
By IronManLXIV, with 2 replies.
Last reply by IronManLXIV, about 1 year ago:
Thank you!:)
World lagging while scrolling
By Mauckenweg, with 10 replies.
Last reply by danpost, about 1 year ago:
Mauckenweg wrote...
ok ill try it i dont fully get how to implement the code of the Scroller class How do I need to change the world code to make it work?
The tutorial has just about all the information you should need.
How do i permanently remove an object.
By alex90, with 5 replies.
Last reply by danpost, about 1 year ago:
alex90 wrote...
if i try to delete it then it says thatvariable isnt declared << Code Omitted >> this is the code
You have 9 different worlds. That is not bad, in and of itself; but, I am sure it would be taxing on memory if you all of them existing at the same time. So, my first suggestion may not be the best approach. Since I do not know anything about your worlds, no suggestion can be formulated at this time. Please provide world class codes for which cat is initially located. Now, if there was a way to "save" your worlds using minimal data (without saving the worlds themsel
I wanna make a cage fall from the sky
By KCee, with 1 reply.
Replied to by danpost, about 1 year ago:
KCee wrote...
I have a rope trap that upon contact with the animal, I want to trigger a cage above the animal to fall down, and trap the animal under it for a couple of seconds. how would i make the cage fall down? << Code Omitted >>
In line 27 of
Rope
class, you probably want the y-coordinate of the
addObject
line to be zero. Then, in the
act
method of the
Cage
class, you need the falling code:
I want my trap to only activate when an animal touches the centre of the image
By KCee, with 1 reply.
Replied to by danpost, about 1 year ago:
KCee wrote...
I have a bear trap class thats supposed to activate and play a closing animation , holding the animal in place for a few seconds and dealing a bit of damage . The problem is that the animation is playing as soon as the animal touches the edge of the trap, so it holds the animal in place and does damage, but the animal isnt in the bear trap, its to the right or left of it. How would i make it activate only when it touches the centre of the image. << Code Omitted >>
Use the
getOneObjectAtOffset
method:
Help with J Option pane
By Mitchell.School, with 4 replies.
Last reply by danpost, about 1 year ago:
Mitchell.School wrote...
still repeats itself even if i enter 1-3 which is weird because the squareValue input works and this one works if i have it be triggered by pressing a key << Code Omitted >> because that works but the other one doesn't
The code provided by myself was tested before posting. I am quite sure it, by itself, is not the problem. Please show your updated code.
I wanna make an electric effect that stuns animals that touch it for a few seconds
By KCee, with 3 replies.
Last reply by danpost, about 1 year ago:
KCee wrote...
how would i make the animal stay in place? would i put (speed = 0) under health--;?
I thought I took care of that with line 12. However, it seems to be misplaced. Move line 12 two lines down to have lines 6 through 15 look like this: <Code Omitted>As long as the provided code is placed in the act method before the movement code, It should now work as required.
I have a poison trap that I want to deal tick damage (damage overtime)
By KCee, with 6 replies.
Last reply by danpost, about 1 year ago:
KCee wrote...
wait does the poison only deal damage while the animal is in contact with it or does it deal damage even after its left contact? because i want the animal to be poisoned even after leaving contact with the poison cloud
If being poisoned is to be a state of an animal, then the damage should be controlled by the animal, not by the poison object. So, forget everything I stated above. In
Animal
class, add:
Published my first scenario, but now it is stuck on initializing
By Merten, with 5 replies.
Last reply by danpost, about 1 year ago:
Merten wrote...
<< Codes Omitted >>
You posted all these classes (excepting
Speler
and
Sline_Koning
) for what reason? I cannot be certain, but it might be the use of the
GifImage
class that is causing problems on the site.
I want to assign multiple keys for movement, A and Left Key What would be the code for that ?
By TheGoatFighter, with 2 replies.
Last reply by danpost, about 1 year ago:
TheGoatFighter wrote...
<Code Omitted>It is showing an error and that I can't use &&
Of course not. Only
boolean
values (
true
/
false
) can be
#AND#
ed (using '&&') Also, you do not want the actor to move only if both keys are pressed at the same time. You want "if either key is down", which means you need to
#OR#
('||') the
boolean
values: <Code Omitted>
How to switch images slowly?
By UAT123, with 3 replies.
Last reply by danpost, about 1 year ago:
UAT123 wrote...
Thanks for replying but the image doesn't switch when the food is eaten. I wonder if it has anything to do with this bit of the code: << Code Omitted >>
No. That code should be fine. Please present your current class codes in full.
Can sombody tell me why the game does not work in the second space world?
By stijn.b, with 5 replies.
Last reply by danpost, about 1 year ago:
One way to "fix" it is as follows (in
Shot
class): <Code Omitted>Although there is probably an easier way -- like having an intermediate class between
World
and the two space worlds (maybe
11
12
13
14
15
16
17
X