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
Collision detect
By alinasomcutean, with 3 replies.
Last reply by Super_Hippo, over 9 years ago:
Two classes will never collide. One object of a class can collide with another object. So either you get a reference to the Die object when a collision was detected in the Personaj class or the Die object needs to get a reference to at least one of the other objects.
Pixel Color Change
By ironphoenix20, with 3 replies.
Last reply by danpost, over 9 years ago:
ironphoenix20 wrote...
My image is an actor so how do I get the x and y of my mouseClick. Would that be the same as the x and y of the pixel?
That would certainly not be the same (unless the top-left corner of the image of the actor was at the top-left corner of the world window). The location of the actor, (x, y), would be the center point of its image. So (x-getImage().getWidth()/2, y-getImage().getHeight()/2) would be the world coorindate of the top-left corner of the actor's image. Subtracting that from the point the mouse was clicked at would produce the (x, y) of the image wher
enemies follow player without moving into wall
By mr.tim_r, with 1 reply.
Replied to by danpost, over 9 years ago:
There are various ways to do that. Using a "line-of-sight" object is one of the most common ways. Also, it may help to keep the last location of chased player in an enemy that had one in its sights (so the enemy could proceed toward that location (when the player moves behind a wall) to see if sight on the player can be re-acquired (if no other player is currently in sight).
Here
is a link to an earlier discussion on a LineOfSight object.
HELP ASAP java.lang.IllegalStateException: Actor not in world.
By ttrussell, with 2 replies.
Last reply by ttrussell, over 9 years ago:
I actually just found a fix myself i changed the checkFlyingsaucerHit and checkAsteroidHit to a single method public void act() { if(life <= 0) { getWorld().removeObject(this); return; } else { life--; move(); checkAHit(); } } private void checkAHit() { FlyingSaucer flyingsaucer = (FlyingSaucer) getOneIntersectingObject(FlyingSaucer.class); if (flyingsaucer != null){ getWorld().removeObject(this); flyingsau
Why can't I save the world?
By Alola_Sandslash, with 1 reply.
Replied to by danpost, over 9 years ago:
Alola_Sandslash wrote...
Why can't I save the world when I am inside of a world that is not the first one to load. Is there anyway to be able to do it?
You can temporarily make it the first one by manually creating a world of that type. When done, manually create the world that is to be first to make it first.
Why doesn't this code work?
By Wasupmacuz, with 15 replies.
Last reply by Wasupmacuz, over 9 years ago:
Yehuda wrote...
The coordinates for the drawString method are that the X puts the left side of the first letter at the specified X, but the Y puts the bottom of the text as the specified Y so since your text is 11 pixels high you have to set the Y for drawString as at least 11.
Thank you Yehuda :)
Create Title Page
By suge5, with 3 replies.
Last reply by danpost, over 9 years ago:
The started method along with the 'world' field should go in your title screen world (the picture saying "press anywhere to start"). Manually create the world after you move them into it. See my last post as to what to put in the Instructions world class.
Please Help Me!
By suge5, with 2 replies.
Last reply by suge5, over 9 years ago:
Still Having a little trouble...
public class FrogHunter extends Actor { public void act(){ if(Greenfoot.mouseMoved(null)) { //whenever the mouse is moved MouseInfo mouse = Greenfoot.getMouseInfo(); // obtains information from the mouse setLocation(mouse.getX(), mouse.getY()); // sets the locaion of the bat to where the user places the mouse in the world } if(Greenfoot.mouseClicked(null)) { //finds all ibjects int x = -getImage().getWidth()/2; //sets location of bat you can hit animal with i
Greenfoot chapter 4
By Ethan, with 2 replies.
Last reply by Ethan, over 9 years ago:
Thanks!
I need a finish line
By Student3111, with 3 replies.
Last reply by danpost, over 9 years ago:
Something like the following should work in the car class(es): <Code Omitted>An int timer field in the YouLose class can be used to delay going to the next level.
health bar
By kursatA, with 5 replies.
Last reply by RustuMan, over 9 years ago:
kursatA wrote...
RustuMan wrote...
kursatA wrote...
r u my dad?
calm down mate
whos you
I am your father
How to make counter display ammo?
By wowi132, with 1 reply.
Replied to by danpost, over 9 years ago:
For a helping suggestion -- do not track the same value in multiple places. Either use the 'totalCount' field of the Counter1 object to track the amount of ammo or use a simple Actor object to display the text representation of the amount of ammo in the 'ammo' field of the Ditzel class. However, do not use both fields.
Help
By alinasomcutean, with 3 replies.
Last reply by danpost, over 9 years ago:
Instead of removing an adding the girl,, just set her location. For example <Code Omitted>
Sprite Creation
By BrownDwarf, with 4 replies.
Last reply by danpost, over 9 years ago:
You can avoid that problem by building each piece from four simple (square) blocks. Each piece has a shape that can be described within an array. The piece actor can be made invisible (transparent image) and can control the rotation and location of its blocks. The blocks can inform the piece actor if any collisions occur during a move or rotation to cancel (undo) the action.
anchor
By Yehuda, with 5 replies.
Last reply by Yehuda, over 9 years ago:
Thank you. I should have figured that out after I read "
How to Use GridBagLayout
" which did speak about having all the components clumped in the middle or setting them to not be, but I got led away when they spoke about the reason for the components being clumped in the middle is because the user
might
have enlarged the frame, so I wasn't thinking of a JPanel being originally too big.
353
354
355
356
357
358
359
X