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 to Check Very Specific Collision for Platformer
By Geotan, with 7 replies.
Last reply by danpost, over 10 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 10 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 10 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 10 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 10 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 10 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 10 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 10 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 10 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 10 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 10 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 10 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 10 years ago:
Thanks
Game Troubles
By DogeOverlord, with 10 replies.
Last reply by DogeOverlord, over 10 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 10 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
477
478
479
480
481
482
483
X