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
why is skipping the whole of the first round
By divinity, with 11 replies.
Last reply by danpost, over 9 years ago:
You should probably get the random numbers for the problem before the for loop where the user attempts to answer it.
Health for Actors
By bintin125, with 1 reply.
Replied to by danpost, over 9 years ago:
All you need is an instance int field for the number of hits required to kill the actor. Lower its value each time the actor is hit. When the value is lowered to the value of zero, remove the actor. If the enemy is not removed when touching the actor, you will need to track the touching state to determine when the touch occurs (as opposed to knowing if it is currently touching or not). This is so that you are not be constantly decrementing the value of health while the same occurrence of the touch continues.
Help With an Error?
By nathanathan, with 14 replies.
Last reply by danpost, over 9 years ago:
I forgot to mention, setting 'vSpeed' to zero should be done when found on ground (in the 'onGround' method); and for falling, use something like this: <Code Omitted>
Help with some programming
By madarnt, with 6 replies.
Last reply by danpost, over 9 years ago:
The boolean is to track the state of the "e" key -- so you can detect when it is initially pressed or released: <Code Omitted>
How to Check Very Specific Collision for Platformer
By Geotan, with 7 replies.
Last reply by danpost, over 9 years ago:
Geotan wrote...
Thanks for pointing that out. Luckily in this game the pictures are just squares, but I may make something using this code later.
Later, you may end up improving the code even more. To see my way of creating a jump-n-run type movement, check out my
Jump and Run Demo w/Moving Platform
scenario.
a varible in Actor class,How to use it in world class?
By limingbogf, with 4 replies.
Last reply by limingbogf, over 9 years ago:
think you very much!l have solved it.
Missing or unreadable API documentation for actor class.
By Klxvixn, with 1 reply.
Replied to by Super_Hippo, over 9 years ago:
If you use a the current version of Greenfoot, you can just change the method names to be able to use them in the Actor class: canSee → isTouching eat → removeTouching You can also find the API online:
http://www.greenfoot.org/files/javadoc/
random to controlled movement
By tRapkIng, with 1 reply.
Replied to by Super_Hippo, over 9 years ago:
You could use a boolean field to decide which method to execute. <Code Omitted>
NullPointerException when making a list.
By jamieMatthews, with 1 reply.
Replied to by jamieMatthews, over 9 years ago:
Okay, nevermind. The issue was I was calling this method during the preparing phase. The spaceship was already made, but I found a workaround.
NullPointerException when spawning objects
By Hydrowarrior, with 1 reply.
Replied to by danpost, over 9 years ago:
You are removing the actor from the world before calling the 'SpawnTile' method (which requires the actor be in a world because you cannot call a method, like 'addObject' on 'getWorld' when 'getWorld' returns a 'null' value). Remove the act after calling 'SpawnTile', which can be simplified to this: <Code Omitted>
How to create an interface
By Vicidsmart, with 1 reply.
Replied to by danpost, over 9 years ago:
Vicidsmart wrote...
I just don't know where to click to create one. I only know how to create worlds and actors.
On the menubar, try 'Edit>New Class...'. Just change the word 'class' to 'interface' in the editor. Of course, you could create any type class (World subclass or Actor subclass, for examples) and clear it of all initial code and start by adding the following to the class: <Code Omitted>The greenfoot application should be able to sort out where the
SCORE COUNTER
By LYNX, with 5 replies.
Last reply by danpost, over 9 years ago:
If not removing the touched actor, an instance field to track the touching state is needed: <Code Omitted>Adding the tracking field allows you to detect when the state changes instead of just knowing the current state. Of course, your touched actor is not of the Scorer class and you should adjust the name to suit your class.
counter won't continue to level 2?
By Sir_brandon_, with 1 reply.
Replied to by danpost, over 9 years ago:
The 'prepare' method in the Level_2 class does not add the counter into the world.
Why is my game pausing
By Valkyrie.exe, with 1 reply.
Replied to by danpost, over 9 years ago:
You will need to supply the code related to the issue -- particularly the code of the player.
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).
475
476
477
478
479
480
481
X