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
Need help with an array
By kdbailey, with 1 reply.
Replied to by davmac, over 11 years ago:
Line 22: <Code Omitted> This creates a variable which can hold a reference to an array, but it doesn't create an array. Nowhere in your code is an array created, so there is no array; 'thisDeck' remains
null
. When you try to use it, you would get a NullPointerException. You need to initialise the variable with an array: <Code Omitted> (By the way, if you need help with an exception,
please
post the stack trace or at least say which line you get the exception on! This makes it much easier to diagnose.)
Help spawning into world of selected stages
By RagingAsian, with 28 replies.
Last reply by RagingAsian, over 11 years ago:
Should they stay private or change them to public? I posted the scenario as well on my profile.
Turns
By sophiaking, with no replies.
in my game i have a computer player and the payer controlled by a person and i want them to take turn in attacks. I'm using this code to assign the attacks if (BattleStage.turn == 1) { System.out.println("turn " +BattleStage.turn); Attack(); } however I'm stuck on making the attack happen after each other and going on until someone dies
I Need Help With Some Random Spawning
By Mikeburdge, with 6 replies.
Last reply by LordLuhar, over 11 years ago:
Yeah put them in both, once in the world code, and once in the food code
How to get an object to push another object forward in the same direction?
By LaffyTaffy65, with 5 replies.
Last reply by danpost, over 11 years ago:
Like I said, that code was not going to be exactly what you needed. You will have to determine which way to move the ball and move it in the proper direction. Unfortunately, I am short on time at the moment and will probably be out for several hours.
2D arrays
By KiwiMC1482, with 15 replies.
Last reply by danpost, over 11 years ago:
First issue: the 'adjustToGrid' method was created to accommodate square grid-cells. You will need two separate fields, 'gridCellX' and 'gridCellY', instead of the one field, 'gridCellSize' for the dimensions (width and height) of one grid-cell. Second issue (maybe): if the size of your Background world is not at least (1050, 600), then you will have an issue. After removing the declaration of the field 'gridCellSize' and adding in 'gridCellX' and 'gridCellY', you will need to set the value of those fields in your 'createVariable' method. Then change the 'adjustToGrid' method to this:
CLICKING a button and creating an actor
By KiwiMC1482, with 10 replies.
Last reply by KiwiMC1482, over 11 years ago:
Okay so far i have <Code Omitted> which complies fine but doesn't actually delete the last minim created and I don't really know what i'm doing wrong
What am i doing wrong?
By RICHJAMA, with 20 replies.
Last reply by danpost, over 11 years ago:
I do not understand what you mean. I do not see 'setDirection' nor 'atWorldEdge' in that list. Also, the 'move' method inherited has one int parameter and you are trying to call one without any parameters; so, the one you are calling is non-existent.
5 in 1
By ZwaineOnGFoot, with 1 reply.
Replied to by danpost, over 11 years ago:
This should be categorized under 'Other', not 'Programming'. However, the answer is yes. My
Clock/StockWatch/Timer
scenario uses different worlds to run the different applications. This show the ability of both the choice making and of multiple projects in one. To show the versatility of greenfoot -- how about two games in one. Check out my
PIP Actor Class
scenario (not that you would want something like that).
attack the direction im looking thanks !
By CodeDaySwag, with 11 replies.
Last reply by danpost, over 11 years ago:
First create a subclass of Actor to display the message; then give it the behavior (using the act method) to remove itself upon "whatever" key press.
Please!!!! Help im stuck with this
By RICHJAMA, with 6 replies.
Last reply by RICHJAMA, over 11 years ago:
oky thank you so much im new to green foot so my methods be out of whack. i have changed the 'if' statements and also the '17' and it helped tremendously.
How Do You Restart A Level When You Die
By BashBashAttack, with 3 replies.
Last reply by danpost, over 11 years ago:
You must be adding your actors into the world manually. They will not reappear when you reset unless you 'Save the World' after adding them. You cannot 'Save the World' once any act cycles have been executed; so, do this immediately after you have placed all your actors where you want them.
How to access a variable from another class.
By Jeb_CC, with 9 replies.
Last reply by danpost, over 11 years ago:
If you are going to assign 'card2' with an object, then there are several ways to go about it. One is passing the Card2 object to the Card constructor; one is finding the Card2 object when the Card object is placed into the world; and, another is using a method call to set a Card2 object to the field. The first and third ways are quite similar, in that they use parameters to the methods to pass the Card2 object to the "new" Card object. The second way, uses brute force to find the Card2 object in the world to get the object to be referenced in the field. Summary of the first and third ways
Help Displaying a Message and then Removing it
By shooterbooth, with 3 replies.
Last reply by danpost, over 11 years ago:
An easier way for the temporary message is to subclass the Message class with a TempMessage class with the timer int field and an act method to run the timer and remove itself when the timer is exhausted. That would keep the code cleaner in the class above and well as clean timer code. <Code Omitted>Then, to adjust the code Super_Hippo
Removing Objects
By Tylon619, with 1 reply.
Replied to by danpost, over 11 years ago:
You referred to the action "remove objects" and the location "bottom of my screen". For the first, you need to find the correct method (which should not be too difficult; although you may want to ask yourself "what am I trying to remove the object from?"). For the second, ask yourself "how do I know when a location is at the bottom edge of the screen?". The answers are (1) the world; and (2) when the y-coordinate of the location is equal to one less than the height of the world. Hopefully, that will lead you along the correct path to the solution.
592
593
594
595
596
597
598
X