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
Condensing multiple classes into one
By JeSuisFish, with 3 replies.
Last reply by danpost, over 8 years ago:
You just need an identifier in the combined classes (Tank, Turret and Shell) -- probably an int field to distinguish one from another (using values from zero to three). Add methods to the classes to return the identification number so that other objects can determine which they are.
Counter isn't counting!
By johnmir19, with 4 replies.
Last reply by johnmir19, over 8 years ago:
Thank you! I really appreciate it! I'll let you know if it works!
Possible to make changeable method and change it accordingly.
By nat12, with 1 reply.
Replied to by danpost, over 8 years ago:
Remove the line declaring bossHP from the boss class and the line declaring enemyHP from the enemy class. Then, wherever either is used in the two classes, change it (either 'bossHP' or 'enemyHP') to just 'hp'. Finally, declare 'hp' in the superclass and change 'VARIABLE' to 'hp' in that class as well. In other words, you want to declare 'hp' for all instances of the superclass (which include instances of its subclasses) in the superclass. Any methods you might have to adjust the value of the health in the subclasses can also be move into the superclass. Each subclass can set its own st
objectsatoffset -> return??
By LegendofLife, with 6 replies.
Last reply by danpost, over 8 years ago:
LegendofLife wrote...
how to use that "null"
Just as given
<Code Omitted>If no wand is detected at the location, a 'null' value is returned.
How to limit spawning?
By Penlos, with 11 replies.
Last reply by danpost, over 8 years ago:
Penlos wrote...
now, if I do nothing and kill no birds I get a problem: java.lang.NullPointerException at Bird.act(Bird.java:41)
Need to see the Bird class codes. Indicate which line is line 41.
Random spawning
By alexaa, with 6 replies.
Last reply by danpost, over 8 years ago:
alexaa wrote...
How would i get the orbs to not spawn a ton at a time? I was trying to only get one or two to spawn every couple of seconds. I got it to work but it spawns a ton at a time.
In this line of the 'randomSpawn' method: <Code Omitted>either decrease the '60' or increase the '100' (or both).
How to click menu to have sound
By Archimedes007, with 8 replies.
Last reply by Super_Hippo, over 8 years ago:
<Code Omitted> Then, when changing the world from an actor in the world: <Code Omitted>
Start world in middle
By Trystar360, with 1 reply.
Replied to by Super_Hippo, over 8 years ago:
In line 44, instead of x and y, you could use x-14 and y-14.
use variable from specific instance of an actor
By Trystar360, with 2 replies.
Last reply by Trystar360, over 8 years ago:
I have an actor and i have 4 booleans telling if there are walls on the left, right, up or down. then i need to use that in a different actor to know if it can move or not. the actor i need the booleans from.
isTouching Error
By Archimedes007, with 7 replies.
Last reply by danpost, over 8 years ago:
Archimedes007 wrote...
where can i put that code buddy ?
Like I said before:
Best place to put the line is immediately after the 'addScore' line.
Change 'getScore()' in the line being inserted to 'score'.
Loop enemy spawning
By KimoDev, with 2 replies.
Last reply by danpost, over 8 years ago:
The loop is what is causing multiples to be spawned at once. Use an if statement with a random chance to spawn.
Solid Wall
By Kevroa, with 3 replies.
Last reply by danpost, over 8 years ago:
Okay, first thing that needs done is to add variables to hold what movement was done. The character can move either way horizontally and vertically. So, a variable for change along the x-axis and a variable for change along the y-axis are needed. Your act method will now look like this: <Code Omitted>Now, that dx and dy are there,
Problem with isTouching
By Dirgantara007, with 1 reply.
Replied to by Super_Hippo, over 8 years ago:
Reason for the error: The actor is removed from the world and then you are calling a method which requires the actor to be in the world (in this case 'isTouching'). When the actor is removed from the world, the current act method will be finished. I don't really know why you need this code at all. You earlier check for the intersection with the Alien. If you want it to be removed, then remove it there. The 'toRemove' variable also seems to be useless.
how to move to next level
By ali18, with 6 replies.
Last reply by ali18, over 8 years ago:
Thank you very much. This is working very well now.
Condense code
By Trystar360, with 15 replies.
Last reply by Super_Hippo, over 8 years ago:
My map should have been this (forgot all the commas)... <Code Omitted> It's up to you if you prefer numbers or letters, it should do the same.
342
343
344
345
346
347
348
X