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
Transfer values from world class to an actor class and vice versa
By Ramrun, with 3 replies.
Last reply by danpost, over 1 year ago:
Ramrun wrote...
In one of my cases, the value of three int variables is determined in the subworld class 'Bloodstream' in the following code: << Code Omitted >> It should then be possible to use these three variables in the actor subclass 'whitecell' That is my try: <Code Omitted>
Assuming the variables in question are declared
static
, all you need do is put the class name first (before the variable names) on the right side of the 3 lines. If they are not
I need help publishing my game
By SaltyBacon, with 4 replies.
Last reply by danpost, over 1 year ago:
SaltyBacon wrote...
It didn't fix it. do you have any other ideas?
There is one in your
Counter
class and one in your
HealthCounter
class as well. If it does not work after changing those also, you may have to consider loading the music files on the fly, instead of right at the beginning. For example: <Code Omitted>You would then have to check if the val
How to make actor switch between two images
By BigDogAlex, with 4 replies.
Last reply by BigDogAlex, over 1 year ago:
Thank you for the help.
hello i am new here working on a project
By jaymesww, with 2 replies.
Last reply by jaymesww, over 1 year ago:
thank you danpost
how to make objects spawn in a certain place
By big, with 1 reply.
Replied to by danpost, over 1 year ago:
big wrote...
how to make objects spawn in a certain place
The
addObject
method has two
int
parameters for the x- and y-coordinate values at which to place an object. If you want specific help, show your current codes and explain, in detail, what it is you wish to accomplish. Then, explain how it is not doing what you want and what you think needs to be changed.
Running Greenfoot on M1
By xilefP, with no replies.
Hi, has anybody experience with installing Greenfoot on M1 Macs? I didn't find anything about it on “the internet”.
I know that it is currently not officially supported.
Cheers xilefP
Limit the Spawner
By Mzarifin58, with 4 replies.
Last reply by danpost, over 1 year ago:
Mzarifin58 wrote...
I have try your program, but why does the enemy spawn all at once? And them spawn continuosly
They should not. Please show your code (entire class please).
Creating a Game
By Lolboy123, with 1 reply.
Replied to by danpost, over 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, over 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, over 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, over 1 year ago:
Thank you!:)
World lagging while scrolling
By Mauckenweg, with 10 replies.
Last reply by danpost, over 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, over 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, over 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, over 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:
16
17
18
19
20
21
22
X