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
Contact during the whole time if object1 via object2
By Bolla13, with 1 reply.
Replied to by danpost, about 7 years ago:
Bolla13 wrote...
I want whoever a lobster sees a crab to only get one life ripped off. The problem is that the crab "crawls" over the lobster and has about 5 times contact = lifetime is deducted.
Your solution might work (with some minor adjustments) if not for two issues. The first one is that you probably have multiple lobsters in the world. A boolean field like
hits
would only detect (a) crab intersect any, but unknown, lobster; or (b) crab not touching any at all. That is, it does not track which lobster is intersecting. So, if a 2nd one touches while one is already inte
Hide cursor in Greenfoot 3.5.0 onwards
By AlexDascalu, with no replies.
I am trying to update the code for a Greenfoot game I made so that the mouse cursor is hidden. In previous version I manage to do that with some Swing code but since 3.5.0 switched from Swing to JavaFX that code no longer works. I know how to set the cursor if I have a reference to the JavaFX Scene, and I have found in the source code the GreenfootStage class which extends Stage, but I can not find a way to access the GreenfootStage of the game. Can anyone please help me?
How to respawn an object(s)
By jonah420123, with 3 replies.
Last reply by ErnieBoi, about 7 years ago:
danpost wrote...
jonah420123 wrote...
I have coded the button to disappear on touch but I cant figure out how to make the coins spawn in when the button disappears. I don't know what code to show so if you need any just let me know.
Show any and all codes related to the button. Also include any attempt to spawn the coins when the button disappears or provide what ideas you might have for implementing it.
I am th fan of yours i am ernie you are great greenfoot man yes yes
How to hide actors in the left pane
By AlexDascalu, with no replies.
Hello! I have made a game in Greenfoot that is intended to be used for educational purposes, and I am trying to find a way to hide some of the actors of my game from showing up in the left pane of Greenfoot, so as to make the game less intimidating to a pupil. I could not find anything like that in the API or on the Internet. Does anyone know if there is a way to do that?
yahtzee code
By BlueberryGaming, with 1 reply.
Replied to by danpost, about 7 years ago:
BlueberryGaming wrote...
i am trying to figure out in a case statement/switch statement how to make large straight and small straight we have the die value named as die Value and roll total
Use an array for the individual die values: <Code Omitted>then sort them in ascending order and iterate thru them to find the straights:
Cant find symbol (variable disk)
By jonah420123, with 1 reply.
Replied to by danpost, about 7 years ago:
jonah420123 wrote...
if(disk!=null) <------ says it "cannot find symbol" here as well ... arena.removeObject(disk); <------- says that it cannot find symbol here
Apparently, you have not initialized a variable called
disk
before trying to reference it: <Code Omitted>Once it is initialized, you will need an assignment statement: <Code Omitted>to possibly acquire a reference to a disk object. Then your
if
statement will have a chance to be
true
as well as
false
(provided your assignment may or may not actually a
how to reset a number??
By Toodumbtocode, with 1 reply.
Replied to by danpost, about 7 years ago:
Toodumbtocode wrote...
like how do you reset a score after it gets to a certain number??? thank you
No code, no details -- No help. Always include related codes and specifics. The code should include some attempt at trying to accomplish what you are having difficulty with.
Problem mit dem Kontakt zweier Objekte
By Bolla13, with 1 reply.
Replied to by Bolla13, about 7 years ago:
Hier noch mein Code Versuch: Ich habe eine Variabel deklariert boolean treffer = true; In der Methode public void lookforcrab() { If (canSee (Crab.class) && treffer) { Crab krabbe1 = (Crab) getOneObjectAtOffset (0,0,Crab.class); If (krabbe1 == null) { treffer = false; } If (treffer) { krabbe1.lebenszeit(-1); } If (Crab.anzLeben == 0) { Eat(Crab.class); Greenfoot.playSound(“au.wav”) Greenfoot.stop(); } } }
Greenfoot Changing Levels - HELP!
By Lewis12374, with 2 replies.
Last reply by Lewis12374, about 7 years ago:
Cheers Hippo
Super_Hippo wrote...
You have an object in a world. You set "currentLevel" to 1. When it touches the "Emblem", it's "currentLevel" will be 2. Now a new world is set, a new (=another) object of this class is added to the world (I guess) and its "currentLevel" is set to 1. If your worlds are similar, then use one class for them. Then you can do something like this:
Wall collision - Question
By Monserus, with 1 reply.
Replied to by danpost, about 7 years ago:
Monserus wrote...
I've added collision to an object (a wall), so the actor can't run through it. It works fine, but everytime I want him to turn around and move in a different direction, he jumps through the wall and gets stuck behind it.
In your
move
methods, you should probably set the desired rotation before moving.
Question about an if statement
By Toodumbtocode, with 1 reply.
Replied to by danpost, about 7 years ago:
Toodumbtocode wrote...
How do you make an if statement to detect if your actor has eaten 3 things? I'll give an example in psuedocode << Psuedocode Omitted >> how do i translate that????
First, you need a field to count the number of treats eaten, call it
treatsEaten
, and a method to make the dog dance, call it
dance
. Then, the translation would be: <Code Omitted>
For Loop - Creating Bricks
By Sangate, with 1 reply.
Replied to by danpost, about 7 years ago:
Sangate wrote...
Hello, I'm trying to create rows like the ones in the Picture << Image Omitted >> With the code below i'm able to create Level 1 (The 1st picture 9x9 Bricks).. But i'm really struggling with the other ones. Could someone help me out? << Code Omitted >>
For the first one, the only things that may be missing are color control, proper horizontal centering and the use of the parameter,
pRows
, within the method. Moving on to Level 2 arrangement, without concern for colors, you just need to restrict the adding of bricks when some condition is
true
. With pr
dodo asaignment 5.5
By plszhelpmeh, with 1 reply.
Replied to by davmac, about 7 years ago:
Please see the
general guidance
for asking for help.
Accuracy Scoreboard Question
By weldon, with 2 replies.
Last reply by weldon, about 7 years ago:
Thanks, I adjusted it and it works now. I'm a bit new to Greenfoot, and I forgot that just using three instances of
Scoreboard
could be easier.
Strings Matching With Alphabet Question
By Zweeg, with 1 reply.
Replied to by danpost, about 7 years ago:
Zweeg wrote...
My code is supposed to recognize if a character in a string I input is a letter or if it is a number/character. I want to remove all numbers/characters and return a string with just the original letters. When I input "h" it returns "h". When I input "3" it returns "". However, when I input "h3" it returns as "h3" instead of just "h". Could you take a look at my code and see what the problem is? << Code Omitted >>
You will find that if you input "3h", it will return "h". In fact, if you input "1234567890h9876543210", it will return "h9876543210". It will return the inpu
231
232
233
234
235
236
237
X