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
Greenfoot Flipping
By JetLennit, with 1 reply.
Replied to by danpost, over 11 years ago:
Please refer to the methods provided in the
GreenfootImage API
.
sort grid i need help
By freeij8949, with no replies.
the order of the two numbers (1 and 2) that we put in the array is fixed. Please think of a way to randomize such order after class. This is my problem.. i can not do that. import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Sets up the SortGrid world. This includes creating all nodes * and numbers, connecting the nodes up and placing them in the world. * * @author Joseph Lenton */ public class SortGrid extends World { private static final int WIDTH = 400; private static final int HEIGHT = 600; private static final int NUMBER_Y = 50; private static final int NUMBER_PADDING = 100; private static final int NUMBER_X = 150; private static final int NUM_POSITIONS = 2; /** * Creates and sets up the SortGrid world ready to be run. */ public SortGrid() { super( WIDTH, HEIGHT, 1 ); // create the network node Node first = new Node();final int leftX = WIDTH/2; addObject( first , leftX, 300 ); // end nodes End ends = new End; for ( int i = 0; i < ends.length; i++ ) { End end = new End(); ends
= end; addObject( end, NUMBER_X + NUMBER_PADDING*i, HEIGHT-NUMBER_Y ); } // create the connections first.setDestinations( ends, ends ); final int randomNums = {1, 2}; final Number numbers = new Number; // make the numbers for ( int i = 0; i < NUM_POSITIONS; i++ ) { final Number number = new Number( randomNums
); final int x = NUMBER_X + NUMBER_PADDING*i; final int y = NUMBER_Y; numbers
= number; addObject( number, x, y ); addObject( new Start(), x, y ); } // set the number destinations numbers.setDestination( first ); numbers.setDestination( first ); // paint ordering setPaintOrder( Number.class, Node.class, Position.class, Start.class ); } } this is my code
Actor Not In World Error
By sametguzelgun, with 9 replies.
Last reply by sametguzelgun, over 11 years ago:
Gevater_Tod4711 wrote...
The problem is in the first code you posted. First in line 9: SWAT SWAT SWAT = new (); This should be SWAT swat = new SWAT(); but that's not the cause of the exception. The problem is that you try to get the location of the swat object in the world. But you have never added it into any world. The swat object is created but never added to the world and so it has got no location and you can't call getX() or getY(); If you first add the object to the world you can get it's location. But only after adding it to the world.
Thank you.
Trouble with getting scoreboard to work
By Griffon305, with 6 replies.
Last reply by Gevater_Tod4711, over 11 years ago:
No I don't think so. But if you change to order of the hitHome and checkCounter method it should work.
cannot find symbol help.
By gonnaownurass, with 3 replies.
Last reply by gonnaownurass, over 11 years ago:
thanks i just turned actor to animal and now its working fine.Thanks
accessing variable from another class
By welleid, with 11 replies.
Last reply by danpost, over 11 years ago:
That's my bad! Should be 'get
One
ObjectAtOffset'.
Help please Turn at world edge?!?
By Snake12163, with 6 replies.
Last reply by danpost, over 11 years ago:
I believe you are thinking correctly: After
executing
a return, no further statements will be executed in that method and execution resumes on the next line of the calling method.
Adding Actors with the Greenfoot.isKeyDown("") method
By Kiara, with 4 replies.
Last reply by Kiara, over 11 years ago:
Thank you both!
image help
By GrimCreeper312, with 9 replies.
Last reply by danpost, over 11 years ago:
You may want to remove the bullet along with 'Boss.life--;'.
wombats2 how to make the Wombat smarter
By jjimenez77, with 3 replies.
Last reply by danpost, over 11 years ago:
The following will find the closest leaf and then make a move toward it (if any found).
Barrier help
By GrimCreeper312, with 13 replies.
Last reply by danpost, over 11 years ago:
Yeah. What you probably should have done, instead of creating a seperate class for each of the Pic#s, is create one class (I would call it Mimic, because it mimics the image) and create one instance of it when the mouse is over a button. Pass it an object of the class the button refers to in the parameter so it can access its image.
How to find actors in radius?
By GreenGoo, with 1 reply.
Replied to by davmac, over 11 years ago:
I need it to return a boolean
You can't make a method return a different type to what it does return. I think what you probably mean is, you want to check whether there exist any actors in a certain radius. In that case, just call getObjectsInRange() and call isEmpty() on the result to check whether there are no actors in range. <Code Omitted> ... will set result to true if there are any actors within a 100 cell radius.
Text input with actors.
By Kiara, with 8 replies.
Last reply by Kiara, over 11 years ago:
THANK YOU!! :)
Jumping
By Kiara, with 6 replies.
Last reply by Kiara, over 11 years ago:
Ummm... I'm not doing this scenario anymore. Thank you both for your help, though.
Creating squares
By mattjames, with 3 replies.
Last reply by mattjames, over 11 years ago:
That's great thanks.
855
856
857
858
859
860
861
X