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
how to get collision getOneIntersectingObject base on actual image (ignore transparent)
By fandyrazzle, with 1 reply.
Replied to by danpost, over 9 years ago:
Actually 'getOneIntersectingObject' will detect a collision when any part of its image intersect any part of the object being looked for. Using the Actor class method' getOneObjectAtOffset(0, 0, Amoeba.class) will do what you suggested the method you were using would do. There is a collision checking method in the Actor class to do what you are wanting; however, it wll list all the objects and there is no method available that will return just one of them like the other two methods above (getIntersectingObjects <> getOneIntersectingObject; getObjectsAtOffset <> getOneObjectAtOffset). The m
Round Display
By StoveAteMe, with 1 reply.
Replied to by danpost, over 9 years ago:
(1) You cannot call methods on a reference variable that has not been assigned an object to reference; line 27 of your MyWorld class declares a new object reference variable of type Text called 'myText' which by default has a 'null' value (it does not yet reference any object; then, the following lines (28 and 29) try to call methods on this variable which does not refer to any Text object to work with. (2) you have 'round' fields declared in both the MyWorld class and the Text class; it is usually not wise to have two different fields to attempt to hold the same information; it is too easy
getIntersectingObject
By CHERNANDEZ95, with 117 replies.
Last reply by DJ_KASKO, over 9 years ago:
Punch That
getting and Error "A Java Exception has occurred"
By maceweilder3, with 1 reply.
Replied to by davmac, over 9 years ago:
Please see the
support page
. You don't necessarily have to send an email (posting here is fine), but you should post all the information that is mentioned there, including the contents of the debug log. Also, are you sure you've accurately copied the error message? Greenfoot itself won't generate that message.
How to make car run fast on track and slow on the grass
By fandyrazzle, with 3 replies.
Last reply by danpost, over 9 years ago:
valdes wrote...
< Quote Omitted > This code will fail if you are on open field (NullPointerException). Make this adjustment: < Code Omitted >
It was presumed that a track of one kind or another will always be there and that the entire world window would be covered by it. However, the inclusion of the extra condition would be a good adjustment as the presumptions I made may not be entirely accurate. Thanks valdes.
How to make an actor follow another actor
By BearProject, with 1 reply.
Replied to by danpost, over 9 years ago:
If you want the healthbar to follow the bear, then I would presume that the healthbar "belongs" to the bear. If that is the case, then the bear should retain a reference to said healthbar and it (the bear) should control the location of the healthbar. At the end of the act method for the bear, you would add a line to reset the location of its healthbar with respect to the <possibly new> current location of the bear.
How do i stop a game over music when i clicked retry button ?
By LonelyGrey, with 1 reply.
Replied to by SPower, over 9 years ago:
I don't think this code even compiles. The mouseClicked method takes an object as its parameter, not a class. In order to keep track of the retry button, you'll have to create an instance variable: <Code Omitted>Then, in your constructor, add it to the world: <Code Omitted> Then for the checking for clicks. Right now, you have the code in your constructor, which runs
only once
, when the world is created. In order to have some code executed with each act cycle, you have to overwrite the act method in the wor
How do I populate an actor with different images?
By lgbrf, with 14 replies.
Last reply by danpost, over 9 years ago:
@StoveAtMe, the 'playerNumber' field gives each player a unique identity (like a name). The 'pNum' variable is just used to hold the value passed until it can be saved in the 'playerNumber' field. Line 10 could just as well have been: <Code Omitted>since both 'pNum' and 'playerNumber' hold the same value at that point. The 'pNum' variable is lost when the contructor end it execution where the 'playerNumber' persists as long the object created exists. By the way, the parameters used should be '0' and '1' -- not '1' and '2' since counting in java starts at ze
Int Health Display Help
By StoveAteMe, with 9 replies.
Last reply by danpost, over 9 years ago:
StoveAteMe wrote...
Okay so, I have a couple of questions, what does the protected statement do, when declaring the method, and why do we need the world variable of type world. And what parameter would I input for the addedToWorld method for it to function correctly?
Adding this method overrides the method with the same name, parameter, and access modifier as the one in the Actor class. The method is called automatically by greenfoot anytime an actor created from the class is added into any world. The method in the Actor class has no implementation (the body of the method between th
Can't call worm class
By xlRenn, with 4 replies.
Last reply by danpost, over 9 years ago:
xlRenn wrote...
Honestly can't find anything different :/
Maybe the difference is in the number of that type object you are creating. You were only creating only one lobster, but are creating multiple worms. Unless you are giving the same counter to each and every worm created or given the field to the class itself instead of each worm (or somewhere else where only one is referenced at all times), you will end up having problems.
Error trying to use "intersects"
By ggongwer, with 5 replies.
Last reply by ggongwer, over 9 years ago:
Thanks for clarifying. I was trying to call it from a sibling class, and that's what generated the error.
HELP, hoe to move an object based on another.
By adesh_dooraree, with 7 replies.
Last reply by danpost, over 9 years ago:
adesh_dooraree wrote...
it cannot find symbols of both getObject in resetplayers(line 46 and 48) and cannot find symbol for resetplayers in score (line 58)
The 'resetPlayers' method is supposed to be in your MyWorld class.
How to make an object explode if it moves too fast?
By zai, with 1 reply.
Replied to by danpost, over 9 years ago:
From what I can tell, the SmoothMover class only tracks the exact location of an actor. I does not retain anything related to speed, direction, velocity or acceleration. The Vector class is used to retain speed and direction; so you should be able to get the length (which is speed) and direction from it
Error
By Abstract, with 18 replies.
Last reply by felipegrigo, over 9 years ago:
Some people see parentheses () instead of curly brakets {} when using Raspberry Pi in big screams. Thats of course wrong.
Help with this scenario in programming please !!
By avishka1, with 1 reply.
Replied to by avi9927, over 9 years ago:
Hi Avishka, Have you got the solution ? Could you please assist me ?
465
466
467
468
469
470
471
X