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
calling a method from another class
By duxbuz, with 9 replies.
Last reply by davmac, almost 13 years ago:
Leaf.class
is standard Java, though you don't see it much in general Java programming. Specifically it is a
class literal
. It is a way of accessing the object representing a particular class (in this case, Leaf!) so that you can, for instance, pass a class as a parameter to a method - which is what you're doing in this case.
E-mailing the game
By GreenAnthony, with 2 replies.
Last reply by GreenAnthony, almost 13 years ago:
Well, thats sad but alright... Thank you!
how to make a moving ground
By Hiimachicken, with 9 replies.
Last reply by danpost, almost 13 years ago:
I have noticed that there is a need to synchronize the movement of the two Ground objects. You can accomplish this by not altering the Ground class I provided above and by having the world act method iterate through all Ground objects and move all of them (both of them) at once: <Code Omitted>
cannot find symbol- method getOneObjectAtOffset(int, int,java.lang.Class<Player>)
By mattman2006, with 1 reply.
Replied to by danpost, almost 13 years ago:
It appears you do not know at what time to use what method. For example, take lines 7 and 8. The first line starts with 'getWorld' which is an Actor class method and the second starts with 'addObject' which is World class method. Unless you wrote one (or both) of those methods into this class, there is a definite problem. The class cannot be both an Actor subclass AND a World subclass, so one of the two lines is faulty. All non-static methods are executed on an object. The object is given before the call. For example:
help with jumping
By Hiimachicken, with 1 reply.
Replied to by danpost, almost 13 years ago:
This would be much easier to code than the normal jump code: (1) being on the ground does not need to be checked; (2) the vertical speed will decrease as long as the key is down; and, (3) the vertical speed will increase as long as the key is not down; which means gravity is no applied while the key is down. This makes it a simple 'if-then-else': <Code Omitted>
atWorldEdge won't work; cannot find symbol - method atWorldEdge()
By duckduckduck, with 2 replies.
Last reply by duckduckduck, almost 13 years ago:
Thank you!!!!
Stop music loop
By Anoniem, with 4 replies.
Last reply by danpost, almost 13 years ago:
Anoniem wrote...
yes i do have a field the code looks likes this now GreenfootSound backgroundMusic = new GreenfootSound("Controlecentrum.mp3"); backgroundMusic.playLoop();
I will presume that these lines are in a method of your World subclass. If those two lines are back-to-back inside a method, then that is a local field and is not good enough. You need to move the first line outside the method to make it a 'global' field (an instance field -- one that belongs to the object that creates it; not one that belongs to the method, where it is discarded after the method is done e
Greenfoot game help
By hollygolightly, with 1 reply.
Replied to by danpost, almost 13 years ago:
There really is no
simple
healthbar. The best I could come up with is an Actor class of about 45 lines, where the main bulk of the code was for creating the image to display (lots of image creation/filling/drawing).
Greenfoot Game Menu
By crimsonred, with 7 replies.
Last reply by crimsonred, almost 13 years ago:
I get how it works now! thank you very much!
How to go to next level after level one?
By duckduckduck, with 3 replies.
Last reply by danpost, almost 13 years ago:
@Osidy, sure. After the incrementing of the number of crates delivered to the depot, put a check to see if 'x' crates have been delivered yet. If so set up a local World field and, depending on which class the current world is an instance of, create the next world and set it active.
aHadAQuestionAboutSomethingOdd
By nickvcg, with 5 replies.
Last reply by nickvcg, almost 13 years ago:
danpost wrote...
You can pretty much remove everything from my Major world act method and call 'run' on your PIP actor in your world constructor.
I figured that part out too now, so now I suppose I need to figure out where to go from here as far as making the bottom half work how I want it to. I've only had 5 or 6 days of CS1010 so far so as far as my experience programming goes, it's basically no where, but I have been catching on quick and already read that whole text book so I'm just trying to make my own stuff now, but your scenario really helps with my next idea! Now I need
How do you pass one actor to another actor ??
By Gerrit, with 4 replies.
Last reply by Gerrit, almost 13 years ago:
i have no idea how to get this done can anyone help me
Why doesn´t appear my scoreboard
By martijn13039, with 9 replies.
Last reply by danpost, almost 13 years ago:
danpost wrote...
The int value should be the final score to be passed to the new scoreboard object.
That means: 'new ScoreBoard(counter.getValue())'.
How to go to next level using a button?
By duckduckduck, with 1 reply.
Replied to by danpost, almost 13 years ago:
Add a subclass of Actor called 'SearchableItems' and have all classes for items that need to be found extend this class. I presume that the items found will be removed from the world when found; so, the Button object can use 'getWorld().getObjects(SearchableItems.class).isEmpty()' to determine if all have been removed.
How to add title page before levels?
By duckduckduck, with 1 reply.
Replied to by danpost, almost 13 years ago:
There are several ways to accomplish this. The easiest way is to make the title page the default background image of your initial world; then, over-ride the 'started' method and move all the code in your world constructor, except for the 'super' call, into it.
730
731
732
733
734
735
736
X