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 do you have an actor shoot if and only if another actor is on screen
By envxity, with 6 replies.
Last reply by danpost, over 1 year ago:
envxity wrote...
1 last question is it possible to make the bullet fire to the enemy as well?
What mechanism do you want for aiming and triggering?
I need help with my brick breakers game.
By 76REINS, with 1 reply.
Replied to by danpost, over 1 year ago:
76REINS wrote...
I am having trouble spacing the lifetokens(Orange Balls) apart from each other
You may want to see my
Value Display Tutorial
scenario. It has a section on non-textual display of values and specifically touches on this type of visual counter.
Why is this giving me a nullPointerExeption?
By ReasonedTiger39, with 3 replies.
Last reply by ReasonedTiger39, over 1 year ago:
Thanks! I have solved the problem. Sorry for the late response.
image.getheight need help
By pxtchey, with 2 replies.
Last reply by danpost, almost 2 years 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, almost 2 years ago:
Thank you a lot!
My Actors dissapear after pressing act or run
By Shaormentiul, with 14 replies.
Last reply by danpost, almost 2 years 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, almost 2 years 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, almost 2 years 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, almost 2 years 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, almost 2 years 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, almost 2 years ago:
Nevermind, I made it work. Thanks for the help a lot!
Saving the caracter
By Guy68, with 9 replies.
Last reply by danpost, almost 2 years 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, almost 2 years 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, almost 2 years 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, almost 2 years 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:
21
22
23
24
25
26
27
X