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 make an actor follow another actor
By BearProject, with 1 reply.
Replied to by danpost, over 10 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 10 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 10 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 10 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 10 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 10 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 10 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 10 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 10 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 10 years ago:
Hi Avishka, Have you got the solution ? Could you please assist me ?
Slowly Spawning Objects
By Validity, with 1 reply.
Replied to by danpost, over 10 years ago:
If you change the '15's to larger values and/or the '6's to smaller values then that will reduce the rate of spawning. Removing one of the 'if' blocks (since they are both the same) will also cut the spawning rate in half (and reduce your code). To be sure, the act() method is the proper place for this spawning code (or a method that is called by the act() method). Different topics of discussion deserve to have a heading (or title) of their own (even when referring to the same scenario).
Update errors in scenario to run in 3.0.3
By gmacias, with 1 reply.
Replied to by gmacias, over 10 years ago:
Never mind! I figured out that I had two different variables in two different classes with the same name. Changing the name of one variable fixed the error.
Making a Game
By Bballbrady22, with no replies.
Okay I am making another stride scenario and a game that I am creating I just don't know what the theme and or music sound effects it should have when programming the game and making it act as if your in the game but when that happens how will I know where I am exactly and how will it be like virtual reality I tried on a virtual reality helmet called oculus and I think it should be similar to that but also different. In a way that attracts the human eye.
Stride - curious question
By SPower, with 2 replies.
Last reply by SPower, over 10 years ago:
Thanks!
How to Randomly add actors around edge of world
By redteam55, with 4 replies.
Last reply by danpost, over 10 years ago:
Newbyfungus wrote...
Do you write that code in the world class?
The code given was written as if in the world class. Whether it should go in your constructor or not depends on whether you are setting up your world (then, yes, constructor) or you are providing game play behavior (then, act method or a method it calls).
467
468
469
470
471
472
473
X