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
What is wrong with my code?
By macaroon72, with 4 replies.
Last reply by macaroon72, over 6 years ago:
Okay, thank you!
1v1 Soccer Game vs AI
By CardJitsu5, with 4 replies.
Last reply by CardJitsu5, over 6 years ago:
danpost wrote...
I do not think you quite understand. You would add and build the method yourself to give the actor that ability. Sure, you would probably call other methods within the method you create (like, in this case,
isTouching
or
getOneIntersectingObject
) and you can find all the ones provided for an actor in the
Actor class API documentation
.
Yeah I'm not great at this at all haha. Thanks for your help mate
Help with multi-key macro
By 444Jam444, with 34 replies.
Last reply by 444Jam444, over 6 years ago:
It works without throwing an exception in the terminal, but there's still the issue of currentIndex not increasing at all within Calculate class, and a new issue of ... Never mind, I made a couple small changes while typing this message which fixed these issues. All I had to do was change '//world.updateDisplay();' from a comment to code (in button class) and add 'Calculator world = ((Calculator)getWorld());' a couple lines above it. For some reason, hitting an operator throws an exception, but I haven't tried resolving that issue so I'll post another reply if I'm having difficulties wit
Polyspiral
By ronald, with 2 replies.
Last reply by ronald, over 6 years ago:
superb thank you
How to change Actor to SmoothMover
By macaroon72, with 3 replies.
Last reply by macaroon72, over 6 years ago:
Actually, I think I got it! Thanks!
Changing Image from an Actor
By greenfish, with 1 reply.
Replied to by danpost, over 6 years ago:
Changing the state (image, in this case) of one
Player
object does not do the same to all
Player
instances. You need to change the image of the one player already in the world (not create a different
Player
object and change its image; as well, that one was never put in the world, so its image is immaterial). Replace your first two lines with this: <Code Omitted>
Is there a way to hide Greenfoot icon?
By greenfish, with 2 replies.
Last reply by greenfish, over 6 years ago:
thank you! it works.
trouble with superclasses
By genju, with 1 reply.
Replied to by Super_Hippo, over 6 years ago:
Your Soldier class has one constructor. The one with a bunch of parameters. The subclasses should have a constructor which exists in the super class. So you could either create a constructor in the Soldier class without parameters. And/or the subclasses constructors should match. So the constructor of your Heavy class could look like this.
Maze generator not working properly.
By EvanRoscTheDev, with 4 replies.
Last reply by danpost, over 6 years ago:
Apparently,
rand
is alternating between 0 and 1 inside the
do
loop, making
x
add and subtract; add and subtract. You need to be very careful with loops and make sure that they will eventually, at some point, be broken out of. Unfortunately, your coding is (1) undocumented; (2) bulky, and not easily readable; and (3) unfactored; -- making it virtually impossible to see what is going on (especially for an outsider). All I can say at this point is that you need better control of the flow within the loop. A visited cell should not be re-visited.
How to increase my score by increments of 1000
By HairyChickens, with 4 replies.
Last reply by HairyChickens, over 6 years ago:
danpost wrote...
HairyChickens wrote...
Thanks for the quick reply but do you mind showing me exactly what I should type for the addedToWorld method and the multiply 1000. This is my first time playing with coding and I'm not familiar it yet :)
The method would look like this: <Code Omitted>An example of multiplying would be taking "score" in line 29 and replacing it with "(score*1000)".
Thank you so much!!!!
How would I display score from another world class?
By DaRafster, with 4 replies.
Last reply by DaRafster, over 6 years ago:
danpost wrote...
Switch lines 17 and 19.
Thank you, this prepare method at the bottom has become a habit for me. I really should bring it up to the top!
How to reverse String?
By JJ24, with 3 replies.
Last reply by danpost, over 6 years ago:
Ways to reverse it yourself might include: <Code Omitted>or <Code Omitted>("resu" is "user" backwards, if you were wondering)
World not being set
By DaRafster, with 7 replies.
Last reply by DaRafster, over 6 years ago:
Sorry, I no longer need to address this problem. This post took a long time to get approved, so I had to find my own way around it.
Actor won't spawn?
By Cooleb, with 9 replies.
Last reply by danpost, over 6 years ago:
When your MyWorld object (or, your world) is created, the initial value of
friendClicked
is set to zero by line 107 (fields are created and set to their initial values before the constructor is executed). Since a constructor is only executed once per object created, the condition on line 31 will always be
true
and the
else
part of that
if-else
structure will never execute. Anything done after initial creation of an object cannot feasibly be coded in the constructor. Sometimes, some finalizing set-up is required once an actor is added to a world or when a world is
Null pointer exception
By scaps, with 1 reply.
Replied to by Super_Hippo, over 6 years ago:
Change ‘world’ in line 20 to ‘getWorld()’. You might want to change ‘projectile’ to ‘new Projectile()’ as well.
129
130
131
132
133
134
135
X