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
I keep getting an Error saying Shiny cannot be cast to Seagull
By Junyi, with 1 reply.
Replied to by Nosson1459, over 9 years ago:
If you want to check for a collision with Shiny class then do: <Code Omitted>
Change Image
By Fatum, with 1 reply.
Replied to by Nosson1459, over 9 years ago:
In your act method just do: <Code Omitted>The for loop will make the variable 'num' be equal to 32 so the image will always be "Wall1.png".
Fatum wrote...
<Code Omitted>
So basically if isTouching(Lazer.class) or not (else) num will be equal to 32. The for loop doesn't make sense because you're setting num = i but there is no other code being
What does this mean?
By JokeNotFound, with 3 replies.
Last reply by Nosson1459, over 9 years ago:
The '%' is the remainder operator. It returns the remainder of the two dividends instead of returning a double (decimal number). So 100 / 55 = 1818181818... (1 + 9/11), but 100 % 55 = 45. So if you do == 0 afterwards that means that there is no remainder meaning that the number is a multiple of 55. The code above will show a 1 when time == 55 and a 2 when time == 110 and so on.
Lifebar in Greenfoot
By elroxar, with 2 replies.
Last reply by Nosson1459, over 9 years ago:
You will only get either 1 or 0 bars since in each case in the switch statement there is only 1 addObject.
Super_Hippo wrote...
Do not create an own class for every life bar. Add a new instance of life bar for every character into the world once when the game starts. When a character loses a life, tell its life bar to change its image accordingly to the lives left.
Points counter?
By OKNEM, with 31 replies.
Last reply by OKNEM, over 9 years ago:
Thank you so much! I got it! Sorry for the really long conversation, but it was worth it! Thanks heaps! :)
how to create the play button on the screen?
By Ajis, with 1 reply.
Replied to by danpost, over 9 years ago:
A button is just an Actor object with one or more possible images that clicks are detected on. I consider a button to be a simple Actor object, meaning no state or implementation need be added into its class. You could simply have this class, which is the entire class: <Code Omitted>Then, create an object from the class, give it an image and test for clicks on it:
NullPointerException error?
By MrMeme, with 1 reply.
Replied to by danpost, over 9 years ago:
The Score object reference field, 'score', in your Enemy1 class is never assigned a Score object and nowhere in the codes given do I see 'new Score()'.
help with my score board
By greenfoothighschooler, with 1 reply.
Replied to by danpost, over 9 years ago:
greenfoothighschooler wrote...
I've already added a scoreboard, and when I click on the voidaddScore() on the counter it adds one point. How do I make it add a point when my laser kills (comes in contact with) an alien, and not when i click voidaddScore() ??
The alien or the laser (whichever is performing the collision detection between the two objects) needs to obtain a reference to the counter object. Usually with something like this (if only one counter object is in the world): <Code Omitted>
how to image manipulate http://www.greenfoot.org/topics#
By Darklord033, with 1 reply.
Replied to by danpost, over 9 years ago:
Darklordd033 wrote...
how to image manipulate http://www.greenfoot.org/topics#
Give a specific example of what you want to do. The topic is too broad to be answered fully here.
how do you change the color of an object in greenfoot?
By queena, with 1 reply.
Replied to by danpost, over 9 years ago:
queena wrote...
how do change the color of an object in greenfoot?
What are you using for images? Are you creating them programmatically -- or do you have different images of the same object in different colors?
How do I create an inventory?
By SallySanban, with 55 replies.
Last reply by danpost, over 9 years ago:
Okay, remove that line I had you put in after line 50 and add the following line at line 81 (using the line numbers of the full class code above): <Code Omitted>
updating texts
By Tyronmi, with 1 reply.
Replied to by Super_Hippo, over 9 years ago:
You can save up to 5 Strings with each up to 50 characters (for each user) with the UserInfo class provided by Greenfoot. It saves them into a .csv file and can get the data from it. You can obviously doing the same with writing the text into a .txt file, but this is not as easy as with the UserInfo class. There are some examples here on the site how to write to a .txt file I doubt that Droidfoot has this option though, but I don't know.
Exponent
By Nosson1459, with 8 replies.
Last reply by Nosson1459, over 9 years ago:
I think you understood me. I was talking about the line of code in StrictMath. I didn't mean it's a method with one line of code in the block I meant that it's one line of code that does whatever it does (the method in C).
Move Actor on Other Side of the World
By itslit, with 4 replies.
Last reply by danpost, over 9 years ago:
The following explains the 'x' part; but, the 'y' part is exactly like it: The code Super_Hippo supplied wraps at -1 and at 600, going to 599 and 0 respectively: ( (x+w)%w, (y+h)%h ) However, we need to wrap at 0 and 599, going to 598 and 1 respectively. By subtracting 1 inside and adding one back outside, we get this: ( ((x-1)+w)%w+1, ((y-1)+h)%h+1 ) This sets the proper lower end for wrapping, but the range is still off by 2 too many, so now we adjust the range (w >> w-2 and h >> h-2): ( ((x-1)+(w-2))%(w-2)+1, ((y-1)+(h-2))%(h-2)+1 } Simplifying, we get this: ( (x+w-
Problem with Reseting the game
By Farizio, with 7 replies.
Last reply by danpost, over 9 years ago:
Farizio wrote...
What I found out was that if I am in the "GameOver" world and restart everything it doesn't matter if I set the world to "Background" or "MainMenue". That means the problem almost has to be in the world "Background".
Please post your GameOver class code for inspection. Possibly it may be a factor.
386
387
388
389
390
391
392
X