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
image.getheight need help
By pxtchey, with 2 replies.
Last reply by danpost, about 1 month ago:
pxtchey wrote...
+ image.getHeight() is throwing a error saying its retrieving a value when its supposed to be a variable if you need the full code for this just let me now
The equal sign on line 23 is the problem.
How can I travel between game levels efficiently without a world for "You beat the level"for each level?
By GreenFinger, with 2 replies.
Last reply by GreenFinger, about 1 month ago:
Thank you a lot!
My Actors dissapear after pressing act or run
By Shaormentiul, with 14 replies.
Last reply by danpost, about 1 month ago:
Shaormentiul wrote...
It might be because I used the same variables in Attack ( the one that I duplicated) but they are private so I dont think thats the problem And Attack2 is just an object I used to see if it would dissapear as well Its not supposed to actually stay on the Scene
The problem is with the code in your
Attack
and
Attack2
act
methods. The 300 milliseconds is 3/10 of one second -- and, you have the object being removed from the time it was created. Well, the internal clock of the computer continues to run even when your scenario is not running.
Game Only Works After Closing Greenfoot
By moko, with 1 reply.
Replied to by Spock47, about 1 month ago:
This kind of problems often occurs when static attributes are used. (e.g. "TestWorld.notes" should be non-static). A static attribute is bound to the class itself instead of the object. So, if you have two testworlds, the static modifier means that you have only one value for notes that is used by both testworlds. So, if notes is changed by one testworld, the change interferes with the other testworld, too. Especially, if you restart your program and a new testworld object is created, it still continues to use the same (already used) notes value that was used in the first run. In constr
How to Append Text to an Existing File in Java
By Niru, with 2 replies.
Last reply by Niru, about 1 month ago:
Spock47 wrote...
You can give the writeString method additional arguments to define how the file is opened. The default is that it "overrides" the file content. By adding the option "APPEND", it will instead append the new text at the end of the file. So, please change line 21 to the following and check whether it works as you want: <Code Omitted> Note: Propably you will have to add the following import statement at the top of your source code: <Code Omitted> Live long and prosper, Spock
getWorldCanvas()
By Nosson1459, with 1 reply.
Replied to by danpost, about 1 month ago:
Nosson1459 wrote...
I'm trying to fix up someone elses old greenfoot code and I came across an error that I don't know how to fix, the person calls a method called getWorldCanvas() from the WorldHandler class Greenfoot doens't know what it is. What is it trying to do and is there a replacement method for it?
I did not research it; but, I believe that it returns a
java.awt.Canvas
object. Being as you cannot upload anything using the
java.awt
package without running into security issues in
javascript
/
HTML
, any scenario using that package will fail to work on a
I am getting an error
By Shaormentiul, with 5 replies.
Last reply by Shaormentiul, about 1 month ago:
Thanks for the help, it doesnt give me the error anymore. The fact that the attack will hit the player creating it wont matter, because it will only affect P2.
Making an attack delay
By Shaormentiul, with 5 replies.
Last reply by Shaormentiul, about 1 month ago:
Nevermind, I made it work. Thanks for the help a lot!
Saving the caracter
By Guy68, with 9 replies.
Last reply by danpost, about 2 months ago:
Guy68 wrote...
Yes but PlayerA is not working because i have two caracters, and i want to choose between them. I wan to play the other levels with the same caracter, without going back to choose the player again. I tryed my best to combine the code but it is not working. Maybe we can go with little steps. I have 2 caracters (Man and a Woman) And i have 3 worlds(MyWorld1,2,3) and I am choosing the caracters in the world Starting. I want to do if i clck on the man in the world satrting that i can play with the man at all 3 worlds and i am able to travell between them(the travelling between worlds
Edge of the world
By Guy68, with 2 replies.
Last reply by Guy68, about 2 months ago:
Thank you! The problem is solved and its working just fine.
Kill multiple actors with a health system in place
By Deepfist, with 1 reply.
Replied to by danpost, about 2 months ago:
Deepfist wrote...
I am trying to make a kill system where, if a bullet hits the Stalker or Sniper, it kills them when their health is low enough. With the Sniper it works, but with the stalker I get the error : << Error Trace Omitted >> The code for both is the same, but with different names and it references the right Actor. The codes for the involved actors will be standing below (The actors it extends to have nothing to do with the code itself) This is the code of the bullet that kills the enemies (not the class Enemies) << Code Omitted >> This is the code of myWorld, it might have some
Casting
By SANELE, with 1 reply.
Replied to by danpost, about 2 months ago:
SANELE wrote...
can someone please explain to me Casting with examples.
Let's say you had in your
MyWorld
class a method that you wanted to call from an
Actor
subclass. Maybe your character dies and you want the world to show a game over screen, so you want to call the
gameOver
method:
Code only execute on first instance
By Makuro, with 3 replies.
Last reply by danpost, about 2 months ago:
Makuro wrote...
<< Codes Omitted >> Thanks for your reply and here are the Game Manager and Background class respectively
I really do not see the need of the
Game_Manager
class. All the information stored in fields there can be determined on the fly, with fair programming. A
Game_Over
class extending
Actor
could be used to show victory or failure and at the same time be used to stop the scenario when added into the world with (in
Game_Over
class): <Code Omitted>Instead of setting fields
Laggy Greenfoot
By Wiwhyweirdo, with 2 replies.
Last reply by danpost, about 2 months ago:
Wiwhyweirdo wrote...
After some more testing I have noticed that whenever I receive damage the game speeds up at gets less laggy. Do what you want with this Information .
You might be doing something with images that is causing the lag issue. Make sure you pre-load your images. Make sure you always reference those pre-loaded images when setting an image. Keep your world at a reasonable size. I stick to not much more than (900, 600) world size (depending on the scenario). If using an unbounded world, make sure all actors are removed from the world after they leave the viewport
Greenfoot scenario freezing in browser
By epm, with no replies.
Hey, I tried to share my scenario but it keeps initialising. After a long time it loads but when changing the world it start freezing again. I really don't know why :( It is working in Greenfoot. You can find my scenario
here!
1
2
3
4
5
6
7
X