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
Issues with respawning
By ErasedBlade, with 4 replies.
Last reply by N0way, over 7 years ago:
on line 6th should be or instead of and(&&) is it? that may be a problem
Help with isTouching() method
By AwesomeKid, with 2 replies.
Last reply by N0way, over 7 years ago:
change line 116 if(getOneIntersectingObject(Lava.class) != null) {
Help with Image and Displaying Text
By CROCKETTROCKETT4, with 1 reply.
Replied to by Super_Hippo, over 7 years ago:
The "Image" method lacks a return type. If it should be the constructor, its name has to be equal to the class' name. Your "GreenfootImage" method has a return type String, but it does not return anything. In fact, the method doesn't do anything. I think it would be clever to let the word methods return one word and not the whole array of words. Then you also don't need to call the methods twice. The "word" method also has a return type String, but doesn't return anything. Keep in mind that the text on an image is not updated when you change the text variable. You need to create a new imag
Open editor description prompt thing
By Olympuss, with 1 reply.
Replied to by Olympuss, over 7 years ago:
Never mind I figured out it was because I opened stride, not Java.
My counter is counting up. But I need it to count the leaves my wombat eats.
By Rawlfish, with 8 replies.
Last reply by danpost, over 7 years ago:
Rawlfish wrote...
Everything was going smooth until I compiled it and for return numOfLeaves; in line 91. It said cannot find symbol - Variable numOfLeaves
True, there is no
numOfLeaves
variable. You could change
numOfLeaves
to
counter.getValue()
.
Scaling the object's height not working
By NoobFected, with 2 replies.
Last reply by NoobFected, over 7 years ago:
thank you
Actor not in world error
By NoobFected, with 4 replies.
Last reply by NoobFected, over 7 years ago:
danpost wrote...
NoobFected wrote...
Is there like a way to fix this though? I still want to keep the setLocation method.
Insert the following immediately before the
setLocation
line: <Code Omitted>
Thanks, it works perfectly now.
Making a shooting laser
By NoobFected, with 10 replies.
Last reply by NoobFected, over 7 years ago:
Thank you!
Animal Sound Board game
By OgresHaveLayers, with 1 reply.
Replied to by danpost, over 7 years ago:
OgresHaveLayers wrote...
need help specifically for playing a sound then pausing for 1 second then playing the next sound and repeating this another 8 times. I also need help with tallying up the points when you click the correct animal.
You can list the sounds, or name of the sounds (which will still require a
GreenfootSound
field for the currently playing sound) in an array and add an int field to track which one is playing (index pointer for array), plus another int field to run the delay timer. That way, either a sound is playing or the timer is running. If timer is runnin
AREA SIZE CHANGE
By gdrgnxxi, with 3 replies.
Last reply by danpost, over 7 years ago:
gdrgnxxi wrote...
thank you! but is there any way to change the size and the color of the font? or should i use other methods? I put the showText on the world where i will flash the text
I do not believe there is any way of changing the size, color or font of text drawn with the
showText
method. You could, however, use an actor to show a text image of specified size and color combination (text color and "color behind the text" background color). The actor could be made to blink on and off by alternating the transparency of its image from full to none and back at regular interva
Mac Greenfoot
By fvila02, with 2 replies.
Last reply by fvila02, over 7 years ago:
Oh ok thank you, I should've realized that tbh. Thanks for the reply :)
Having problem with a code - removeObject does not work!
By NikhilLimaye10, with 2 replies.
Last reply by Super_Hippo, over 7 years ago:
What are you trying to do? You create a new EnemyRespawn object, you add it to the world only to remove it again instantly.
Jumping, falling and platform problem
By AniSusi, with 8 replies.
Last reply by AniSusi, over 7 years ago:
actually nevermind, it works perfectly now for some reason... maybe the platform was just too big? well anyway, thank you all!
Creating a Health Orb
By Syes, with 5 replies.
Last reply by danpost, over 7 years ago:
I was thinking something like this
About Green foot
By bbishal69, with no replies.
Add new asteroids when all have been cleared. Maybe the game should start with just two asteroids, and every time they are cleared away, new ones appear, one more every time. So in the second round, there are three asteroids, in the third round four, and so on. You will have a chance to use generic programming, such as List<>. My code: import greenfoot.*; /** * Space. Something for rockets to fly in. * * @author Michael Kölling * @version 1.2 */ public class Space extends World { private Counter scoreCounter; private int startAsteroids = 2; /** * Create the space and all objects within it. */ public Space() { super(600, 500, 1); GreenfootImage background = getBackground(); background.setColor(Color.BLACK); background.fill(); createStars(300); Rocket rocket = new Rocket(); addObject(rocket, getWidth()/2 + 100, getHeight()/2); addAsteroids(startAsteroids); scoreCounter = new Counter("Score: "); addObject(scoreCounter, 60, 480); Explosion.initializeImages(); ProtonWave.initializeImages(); } /** * Add a given number of asteroids to our world. Asteroids are only added into * the left half of the world. */ private void addAsteroids(int count) { for(int i = 0; i < count; i++) { int x = Greenfoot.getRandomNumber(getWidth()/2); int y = Greenfoot.getRandomNumber(getHeight()/2); addObject(new Asteroid(), x, y); } } /** * Crete a given number of stars in space. */ private void createStars(int number) { GreenfootImage background = getBackground(); for(int i=0; i < number; i++) { int x = Greenfoot.getRandomNumber( getWidth() ); int y = Greenfoot.getRandomNumber( getHeight() ); int color = 120 - Greenfoot.getRandomNumber(100); background.setColor(new Color(color,color,color)); background.fillOval(x, y, 2, 2); } } /** * This method is called when the game is over to display the final score. */ public void gameOver() { addObject(new ScoreBoard(scoreCounter.getValue()), getWidth()/2, getHeight()/2); } /** * This method passed parameter as count of the score */ public void countScore(int count) { /* call the Counter class with method to add score counting */ scoreCounter.add(count); } public void leftOver() { List<Asteroid> leftOver = addObjects(50,Asteroid.class); //Stuck here to call the asteroid!!!! Please help me. Thank you }
196
197
198
199
200
201
202
X