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
Make both players shoot
By rasm214c, with 3 replies.
Last reply by danpost, over 9 years ago:
rasm214c wrote...
but when i use "Greenfoot.isKeyDown" then i will shoot many times a second instead of only once på click? how to solve?
danpost wrote...
Use 'Greenfoot.isKeyDown("?")'
with a timer or a boolean that tracks the state of the key
.
The last phrase says it all. Use it with an int timer or a boolean that tracks the state of the key. A timer will allow continuous regulated shooting while the key is held down. A boolean that tracks the state of the field can be used to only shoot when the key changes state (from up to down or from down to up).
atWorldsEdge help
By Washua, with 2 replies.
Last reply by danpost, over 9 years ago:
If you use the normal world constructor ( 'WorldClassName(int, int, int)' ) and not the other one ( 'WorldClassName(int, int, int,
boolean
)" ), then your actor will never have a negative x-coordinate value. If you try to place or move your actor passed the left edge, it will be place
at
the left edge. In other words, its x-coordinate value will be zero and never go below it.
BACKGROUND MUSIC
By LYNX, with 3 replies.
Last reply by LYNX, over 9 years ago:
Thanks
Game Troubles
By DogeOverlord, with 10 replies.
Last reply by DogeOverlord, over 9 years ago:
I just ended up making it so both SpaceWorlds call getLevel and theres a static boolean called warned so it only warns about the random level once.
Trouble with Randomizer
By LittleMiiMe, with 5 replies.
Last reply by danpost, over 9 years ago:
You only need to understand the concept of the 'this' keyword. It refers to the object that is currently being worked on. It is always an object that is created from the class the word is used. So, you can have an actor remove itself from the world it is in with: <Code Omitted>I added the second line example to show that when a method is called and no object is explicitly given for the method to execute for or on (which is like the first line), then that method is, by default, called on the object the executing metho
Labels
By zobear888, with 4 replies.
Last reply by zobear888, over 9 years ago:
Thank you! I added the code and realized it was off of the screen.
How do I turn an actor without rotating their image?
By bintin125, with 1 reply.
Replied to by danpost, over 9 years ago:
Maintain a zero rotation by saving the direction of movement in a field: <Code Omitted>
Editing .jar files in greenfoot
By bintin125, with 2 replies.
Last reply by bintin125, over 9 years ago:
OK. I'll try that out. Thanks!
World Reset
By Luc_Stoffer, with 1 reply.
Replied to by danpost, over 9 years ago:
Luc_Stoffer wrote...
When I lose my game, a GameOver-Screen appears but if I then press the "Reset Button" and try to run the program again, immediatelly the "GameOver-Screen" appears again... Has anyone a clue where the fault could be?)
You are probably using static fields where you shouldn't -- or you are not initializing their values in your initial world where you should.
How to continue Counter score to different worlds and make a leaderboard score when win or lose?
By Sir_brandon_, with 18 replies.
Last reply by Sir_brandon_, over 9 years ago:
just to make sure everything is correct heres my world
How do I draw a rectangle whitout fill?
By GreenBat, with 1 reply.
Replied to by danpost, over 9 years ago:
The first two parameters of the 'drawRect' method are the location coordinates that the rectangle is to start from on the image it will be drawn on. It is the location where the top-left corner of the rectangle will be. If you place the top-left corner of a rectangle below and to the right of the image, none of the rectangle will be drawn on the image itself. Btw, a new GreenfootImage will have a default drawing color of black; so the last line is not needed: <Code Omitted>This line starts the rectangle at the top-left corner of the created image and gives the
Trouble with getX and getY
By StoveAteMe, with 1 reply.
Replied to by danpost, over 9 years ago:
StoveAteMe wrote...
What I want is when every time I press W, I want to create an object (a missile) from the location of my current movable actor (Savior). I have this much so far but I can't seem to understand what I am doing incorrect. This code is in my actor class "Savior", if that helps at all.
Yes -- knowing the code is in your Savior class help a bunch. You are trying to use the 'getX' and 'getY' methods on the class itself. The class is the script that you write -- not the actor(s) that are created from the class. The class has no location in your world -- the objects create
ScreenReadjusts
By laxmonkey8, with 1 reply.
Replied to by danpost, over 9 years ago:
You probably used the 'clear' method on the background image. The background should remain opaque. If you do 'clear' it, make sure you 'fill' it again with a non-transparent image or color.
using labels and counter
By khoalabear, with 4 replies.
Last reply by danpost, over 9 years ago:
khoalabear wrote...
Just a graphical problem. When it counts up from 0 to 1, the label seems to get blurred. Any reason why?
I cannot say why the image is blurred in such a way. I, for one thing, prefer not to use the 'drawString' method as the image is already set in size and if the new string drawn on it is larger, it is possible to lose the last part of the drawn string off the edge of the image. I prefer to create a text image (using the GreenfootImage constructor that requires the text to be drawn) and then use the 'drawImage' method if needed (the size of the two images ca
How to go after one target
By Bassusour, with 28 replies.
Last reply by danpost, over 9 years ago:
Bassusour wrote...
Now the only problem is the game crashing (The same error codes as I mentioned from my last post) when a missile is in the air, and both players are gone.
Again, you need to post the error trace. Do what I mentioned in my last post.
476
477
478
479
480
481
482
X