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
Problem with removing Objects
By Turbo_Thorsten, with 10 replies.
Last reply by Turbo_Thorsten, over 4 years ago:
Found a Solution
Problem with executing a method from another class
By Turbo_Thorsten, with 7 replies.
Last reply by Turbo_Thorsten, over 4 years ago:
Ok I'm ending this thread bc I found a solution. I don't really understand it but it's working so thank y'all
How add background music and stop when world changes
By Gh0sT, with 3 replies.
Last reply by Gabe1098, over 4 years ago:
oh wait you meant the music I thought you meant the whole project
I got a problem with a Timer
By Turbo_Thorsten, with 4 replies.
Last reply by Turbo_Thorsten, over 4 years ago:
danpost wrote...
Turbo_Thorsten wrote...
The virus and the bacterias should freeze at the same time for the same time but that isn't the case. The bacteria timer is sometimes faster than the virus timer and I don't get why.
For better control, remove timers from both
Virus
and
Bacteria
classes Put a timer in
MyWorld
class and control it from
act
method there. At beginning of
act
methods of the enemy classes, use: <Code Omitted>The
boolean
fields,
freezeVirus
and
freezeBacteria
, are not needed.
My character can move in 8 directions and I can't make it work so that my character can't go past a border(object not the world border).
By Turbo_Thorsten, with 9 replies.
Last reply by Turbo_Thorsten, over 4 years ago:
danpost wrote...
Two problems with it. One is that the moving distance does not match the "rebound" distance (when a border is encountered). The other is "rebound" code does not know which direction of movement caused the collision. Turning 180 does no good unless the actor faces the direction it moved. I would move the "rebound" code into the
checkKeypress
method and rewrite the method as follows:
Problem with removeObjects
By Turbo_Thorsten, with 9 replies.
Last reply by Turbo_Thorsten, over 4 years ago:
danpost wrote...
Super_Hippo wrote...
You remove the actor from the world in line 32. After that, you call the nuke method (line 40). The actor isn’t in the world anymore, so line 57 will never execute.
Move line 32 to after line 46.
Thank you it works!
how do I call
By Gabe1098, with 3 replies.
Last reply by danpost, over 4 years ago:
Gabe1098 wrote...
Thanks! but how do I do a public one?
Same way from within the class (for
this
one). That is, the above line is equivalent to: <Code Omitted>following the standard: <Code Omitted>where 'this' refers to the object the method is executing on (or for). Similar to the English grammar of a sentence -- subject followed by verb. From outside the class where the method is public, a reference to the object of the class the method is in is needed and must be explicitly given. For example:
How can name a certain object?
By Turbo_Thorsten, with 2 replies.
Last reply by Turbo_Thorsten, over 4 years ago:
Gbasire wrote...
You can do this : in a world, for example MyWorld.class : <Code Omitted>and in an actor, for example Player.class : <Code Omitted>
Thank you!
Greenfoot 3.7.0 released
By nccb, with 2 replies.
Last reply by RcCookie, over 4 years ago:
Also, what’s next planned for development?
how can i test for this scenerio
By tennis097, with 1 reply.
Replied to by danpost, over 4 years ago:
If your world is bounded, then the greatest x is getWorld().getWidth()
-1
, and the greatest y is getWorld().getHeight()
-1
.
Index Out of Bounds Error
By Billykid679, with 2 replies.
Last reply by Billykid679, over 4 years ago:
Thanks a lot, I was stuck trying to make it work in the bomb class when I could have just put it in the plane class like you said.
random direction
By pleasehelpwithmycodeyt, with 3 replies.
Last reply by danpost, over 4 years ago:
Maybe: <Code Omitted>
How do you fix the size of the playing screen
By KylesGallery, with 2 replies.
Last reply by KylesGallery, over 4 years ago:
thanks
Array images
By EndlessTimes, with 7 replies.
Last reply by danpost, over 4 years ago:
You could do something like this (where the class of falling objects is called
Falling
and its
static
image array is called
imgSet
): <Code Omitted>
Gold shaking method
By pleasehelpwithmycodeyt, with 1 reply.
Replied to by danpost, over 4 years ago:
Add an
int
timer field: <Code Omitted>Then use something like this: <Code Omitted>
66
67
68
69
70
71
72
X