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
Help with dropping objects.
By radekdv, with 1 reply.
Replied to by danpost, over 10 years ago:
If some or all of your random ships move faster than one pixel per act, they may not actually end up at the location being checked (and therefore, never drop their oil). Please show the entire class code for the Ship objects.
Need help on coding
By lionkitten, with 15 replies.
Last reply by danpost, over 10 years ago:
Which class did you place the 'getScoreBoard' method? it should be in your FilmWorldPLAY class.
Spawning Objects at a fixed distance that scroll across the screen?
By DiplomatikCow, with 6 replies.
Last reply by DiplomatikCow, over 10 years ago:
Ohhhh, I got it now, Thank you so much :D
Actor not in world! Please Help
By SomeRandomStuff, with 7 replies.
Last reply by SomeRandomStuff, over 10 years ago:
danpost wrote...
From your original post code, line 4 calls a method that could potentially remove the actor from the world. If it does, then 'getY' in line 5 must fail because there is no world to get a y coordinate from. You must ensure the actor is still in the world before executing 'getY' on line 5. The proper conditional check would be 'if (getWorld() != null)'. 'getWorld' is an Actor object method that returns the world the actor is in (or 'null' if not currently in a world).
Thank you danpost! Everything is now working! I appreciate you helping me!
Help with scrolling background
By berdie, with 4 replies.
Last reply by berdie, over 10 years ago:
danpost wrote...
Copy/paste what I just posted and see if it does the same. It might be the sign on the last line.
Thanks for your input i already fixed it. My picture wasn't the same size as the world ( U know i can throw myself out the window right know).
Scrolling background
By berdie, with 5 replies.
Last reply by danpost, over 10 years ago:
danpost wrote...
< Quote Omitted > Change the '-' to a '+' on line 24.
This advice was not correct. The correct solution was to change the sign of 'scrollSpeed' on line 7 (in the first code post). It may appear to do the same thing; however, the sign of the field is used in determining scroll break points (see lines 25 and 26 of the first code post). A final thought on that is that the sign of the 'scrollSpeed' should not be needed as a factor in those lines -- if the value of 'scrollPosition' ever got too low or too high, then is was because the sign of the value of 'scrollspeed' w
Help! The world pause when I remove object
By iguru1996, with 3 replies.
Last reply by danpost, over 10 years ago:
The problem is that you cannot write to a file while on the site (security reasons).
How do you create a timer in a greenfoot world or actor class?
By PalmTree, with 1 reply.
Replied to by danpost, over 10 years ago:
A timer will work in either type of class (World or Actor). Just do not try to spawn (or create) actors from its own class. If you do, then if none of that type actor are in the world to begin with, none will ever spawn; and if one is in the world and one produces another, then both produce one more each, then... , the population of that type actor will increase exponentially. Your World subclass is the logical place to spawn objects into the world. You say you tried, but you did not show what you tried; so, it would be difficult to assist you with you code.
One actor following another
By hkinney, with 13 replies.
Last reply by CKnox, over 10 years ago:
OK thankyou thats very helpful!
Jumping Problem
By Space0fAids, with 2 replies.
Last reply by Space0fAids, over 10 years ago:
danpost wrote...
Add a line setting 'onGround' to 'false' in your 'jump' method.
Holy crap. Thanks a lot.
Forward& Back
By pactz, with no replies.
Can anyone make this actor move automatically forward 60px and back 60px like super mario Heres the code: import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class GoldenBall here. * * @author (your name) * @version (a version number or a date) */ public class Lobster extends Actor { /** * Act - do whatever the GoldenBall wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { checkGoldenBall(); } public boolean canMove(int x, int y) { Actor sand; sand=getOneObjectAtOffset(x,y,sandroad.class); //the section below checks if there is a block you can move to // if there is it sets sand to a vlaue otherwise it says null // The errors are in this section boolean flag=false; if (sand !=null) { flag=true; } return flag; } /** * Check if Lobster eats the ball */ private void checkGoldenBall() { Actor GoldenBall= getOneIntersectingObject(GoldenBall.class); if (GoldenBall !=null ) { getWorld().removeObject(GoldenBall); } } }
HELP
By pactz, with 6 replies.
Last reply by pactz, over 10 years ago:
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Alligator here. * * @author (your name) * @version (a version number or a date) */ public class Alligator extends Actor { /** * Act - do whatever the Alligator wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { moveAround(); eat(); } public void moveAround() { move(60); if (Greenfoot.getRandomNumber
Perfect pixel collision
By xFabi, with 13 replies.
Last reply by danpost, over 10 years ago:
xFabi wrote...
So back to my edge() method, can you tell me how to solve that problem?
Remove lines 35, 36 and 41 (from your last class posting) and change line 37 from 'if' to 'else if'.
Selecting A Class And Moving It: Can someone help me please
By TheLlama, with 3 replies.
Last reply by danpost, over 10 years ago:
TheLlama wrote...
Thanks, but how would i keep the tank in the field?
Declare the field outside the method. That is, instead of a variable that is local to a method -- like this: <Code Omitted>You would do this:
adding radom numbers to the screen
By kylecompton31, with 4 replies.
Last reply by xFabi, over 10 years ago:
x,c wasnt actually meant to be values, i just took them to show, that you have to input numbers there :D Edit: ah thats what you meant nvm, i thought you could also define a minimum
612
613
614
615
616
617
618
X