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
Freezing and lagging in this scenario
By JonnyB7, with 8 replies.
Last reply by JonnyB7, over 8 years ago:
Thanks for the advice on both topics. Yeah key control got messed up because I was trying to add directional shooting for the bullets then I forgot to take it out once I realized that was not the way to do it. Thanks, Let you know if I make any progress.
How to change int to String??
By slchoiaa, with 4 replies.
Last reply by danpost, over 8 years ago:
Nosson1459 wrote...
y would u want 2 convert a string to an int
That is not what is happening here. We are taking numeric values and adding their digital characters to a string. However, there are several good reasons why one might want to convert a numeric string into a number. This is often done when a numeric value is input as a string or read as a string from file data.
how to make an image move constantly to the left
By hockeydude1155, with 2 replies.
Last reply by Nosson1459, over 8 years ago:
either <Code Omitted>or<Code Omitted>the diff. is dat "move" will be based on which way background is facing "setLocation" will move left regardless
How to create composite Actors
By MrBradley, with 11 replies.
Last reply by Nosson1459, over 8 years ago:
MrBradley wrote...
I'm looking to build a container to hold multiple Actors. Has this been done before? An example would be to have an adventure hero with a health bar.
u cud make it part of the heroes picture and a field in the hero will change the picture based on how healthy he is, so for example every 4 hits knocks down 1 of 6 bars changing the pic to only show 5 bars left, and so on
Trying to get actor to maintain the scale specified in code for constructor
By JWK3986, with 2 replies.
Last reply by JWK3986, over 8 years ago:
Thank you, that works exactly the way I needed.
if(isTouching(object.class)
By ZoeF, with 3 replies.
Last reply by ZoeF, over 8 years ago:
I like to thank you all for the idees. As i needed to wait 12h to get my post approved i found another solution wich suits me pretty wel. I removed the idee of istouching and worked with 2 arrays in my enemies super.class.
Java help
By Vannaem96, with 1 reply.
Replied to by Super_Hippo, over 8 years ago:
I doubt that you posted the correct code or at least I am not sure how this is related to your question. Well, you could have something like this in your wolf class: <Code Omitted>
Error: actor not in world
By Mitchell025, with 1 reply.
Replied to by Super_Hippo, over 8 years ago:
Put the 'if (life==0)' block at the end of the act method. Right now, when life reaches 0, the kogel is removed from the world. After that, you are trying to get an schip object at the position of the kogel, but the kogel is not in the world anymore, so it can't check for something at its coordinates.
accelerate over time (missile)
By brothermic, with 2 replies.
Last reply by danpost, over 8 years ago:
You probably do not need an 'if' or a 'while'. You can just use something like this: <Code Omitted>
nullpointerexception
By Sepho, with 1 reply.
Replied to by danpost, over 8 years ago:
Switch lines 33 and 37. If you remove the actor (line 33), the 'getWorld' method (line 37) will not return the world, but 'null' (no World referenced).
Need to use an Objects location within an Actor
By Kelvin., with 4 replies.
Last reply by Kelvin., over 8 years ago:
danpost wrote...
Kelvin. wrote...
if the bone is not in range when I start the world it gives me this error?
You cannot expect a bone to be in the list until you are sure that the list is not empty. Cut line 3 and paste it (inserted) at line 6.
You're right it works now. Thanks :3
I don't know how an actor can read a position from another one.
By NymburkSRO, with 1 reply.
Replied to by danpost, over 8 years ago:
NymburkSRO wrote...
What did I do wrong?
Well, the first line is not within the method. This means it will execute only once, when the object is created. However, it will not yet be in any world and you should get a 'nullPointerException' when creating the actor. Now, as long as you ALWAYS have a Delo object in the world, and the 'getPosdelo' method is called from the 'act' method or a method called by the 'act' method, it should work as the first line within the 'getPosdelo' method.
How to get letter input from Greenfoot.ask
By AuroraGamer, with 1 reply.
Replied to by danpost, over 8 years ago:
AuroraGamer wrote...
I would like to ask them wether or not they would like to play again by entering the letter y or n, but I'm not completely sure how to use Greenfoot.ask to do this.
Using 'ask' here might not be the most appropriate way to go about asking for a single character String input; but here we go. Since 'ask' returns a String object, there are two things that you should check for -- a length of one and whether the character is in the String "YyNn". As long as both are not satisfied, the question must be 'ask'ed again (using a while loop). You may even want to add "In
Displaying an array with random numbers on an Image
By arshbhatti8, with 3 replies.
Last reply by danpost, over 8 years ago:
arshbhatti8 wrote...
So, what you are trying to say is that for every random number that i might generate, it will have its own class?
No -- just an separate object from the same class. My
Value Display Tutorial
shows how to make a Counter class, which your new class would be quite similar to; just that instead of an 'adjustValue' method, you may want to use a 'setValue' method.
Stop loop if condition is not met anymore?
By ChristianStachelhaus, with 3 replies.
Last reply by danpost, over 8 years ago:
Another way might be that you make all your instruction methods return a boolean value and place the following line at the end of each one: <Code Omitted>Then, your code would look like this: <Code Omitted>The semi-colon at the end of the while loop acts as an empty block of code to execute (no operations).
430
431
432
433
434
435
436
X