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
Java help
By Vannaem96, with 1 reply.
Replied to by Super_Hippo, almost 10 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, almost 10 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, almost 10 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, almost 10 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., almost 10 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, almost 10 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, almost 10 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, almost 10 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, almost 10 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).
Determining the Actor subclass of mouseInfo.getActor()
By tonyreks, with 3 replies.
Last reply by danpost, almost 10 years ago:
tonyreks wrote...
At that point, I feel like there might as well be an Actor method mouseClickedThis()
The method can not only be used for specific Actor objects, but also the World object; and it can also be used generically, where it does not matter what was clicked on, only that a click was detected. I often use it for specific Actor object where the code is placed in a World subclass. It is also used for cases where one wishes to detect when a mouse button was released (in situations where the pressing of the mouse is either unimportant or dealt with separately).
AI must shoot towards my tank
By brothermic, with 1 reply.
Replied to by danpost, almost 10 years ago:
brothermic wrote...
I wanna write a tankgame. But my enemy's must be able to shoot towards my tank when my tank gets close enough. I have no idea how to make them shoot their bullets or flametrowers etc towards me. I found somewhere it has something to do with vectors correct?
Asked and answered
here
.
I need help with delay/wait
By Sk1llG4m3r, with 1 reply.
Replied to by danpost, almost 10 years ago:
Sk1llG4m3r wrote...
i want that if the actor hits an object that just the actor freezes for 1 second
Add an instance int field to the class to count down the act cycles it is to be frozen for. For each execution of the act method, if the value of the field is zero, then the actor is not frozen (act normally); if it is not zero, decrement its value. When it hits the object in question, set the value of the field to something around 50, or 60. This would look something like the following:
greenfoot.ask
By Everardo_Chao, with 1 reply.
Replied to by danpost, almost 10 years ago:
On this line: <Code Omitted>the single quotes around the three causes it to be treated as the character '3'. The character three has an int value of 51, which, obviously, is not 3. Remove the quotes from around the 3.
getMouseClick
By Everardo_Chao, with 2 replies.
Last reply by Everardo_Chao, almost 10 years ago:
thank you very much!
Damage
By Sepho, with 11 replies.
Last reply by Sepho, almost 10 years ago:
This was just a try. I just want that the zombie dies not with one hit but with few hits depending on the damage the Bullet does. for example: Bullet does 5 damage and the zombie has 10 hitpoint so he dies with 2 hits.
433
434
435
436
437
438
439
X