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
Help
By nx117, with 3 replies.
Last reply by danpost, over 7 years ago:
nx117 wrote...
How do you call a method from another class?
You really need to be more specific. Show the two classes involved and point to what you are trying to access and from where. Non-static methods are always called on an object created from the class the method is in. If no object is explicitly given, then the method is being called from within the class (or from a subclass) and the object is the same as that which the calling method was executing on and can be referenced by the keyword '
this
'. Calling on a object created by a different class, you must explicitly g
I need help creating new objects based on the score
By Alexlife2002003, with 8 replies.
Last reply by Alexlife2002003, over 7 years ago:
oh Wow thanks, I did not notice that
Auf Variable Beziehen
By MrExamined, with 15 replies.
Last reply by MrExamined, over 7 years ago:
Vielen Dank für eure Hilfen, hat mir sehr geholfen.
isTouching only works once
By bommijn, with 2 replies.
Last reply by bommijn, over 7 years ago:
You were right i overlooked this. field Rotation was initialized in my constructor and given a random value which was than assigned to setRotation(). I could have actually used setRotation(Greenfoot.getRandomNumber(...)); When they collide it would set the rotation field from Actor to the new value but not rotation in my class which was used to calculate the new rotation. So it appeared as it was being ignored but it actually just set it to the same amount every time. Thanks for changing my point of view, was clueless here for a while.
Help with Snake Game
By ananyagarg, with 5 replies.
Last reply by danpost, over 7 years ago:
ananyagarg wrote...
If you use the code above, it only works for the first 5 cherries but then doesn't continue to add cherries after the first blueberry is eaten
Line 19 should add a cherry -- not a blueberry.
Having trouble moving invaders left and right
By ananyagarg, with 5 replies.
Last reply by danpost, over 7 years ago:
ananyagarg wrote...
In your game, why do your invaders shoot their bullets so fast, and where is the code in your game that determines the speed in which the bullets move?
The demo was geared toward the movement -- not really anything else. However, the shooting code is in the
Invader
class. The last line in its
act
method partly controls when a shot is fired by having each invader shoot randomly, but on an average of once every 200 act cycles. In the
shoot
method, shooting is further limited to only if the invader is the lowest one in its column. For some unkno
Having trouble about these pattern by using loop
By rickykwl, with 3 replies.
Last reply by danpost, over 7 years ago:
rickykwl wrote...
may i know what means about % and / ?,
The / is just division. Actually, in this case, it is integer division where any fractional remainder is discarded (only because we are working with integer values). The % is the modulus operator. It returns the remainder after division So, as the iterator, i, progresses from 0 to 31, i/8 will be 0 until i=8, then 1 until i=16, etc., while i%8 will repeatedly go from 0 to 7. One complete cycle from 0 to 7 will occur for each "increment" of i/8 (which will go from 0 to 3).
how to impose the multiple conditions for the
SCORE COUNTER
By LELETHU, with 1 reply.
Replied to by mik, over 7 years ago:
You might like to have a look at
this video
. The score counter starts at about 5:45.
Latest download and/or book scenario is broken for Asteroids
By egertner@monroviaschools.net, with 1 reply.
Replied to by davmac, over 7 years ago:
You need to remove the import of "java.awt.Color" at the top of any class which won't compile. The Greenfoot API changed in version 3.1.0 and some older scenarios aren't compatible with it;
full details here
.
Preventing Users to hold down key to gain infinite points
By CodingIsNotEasy, with 2 replies.
Last reply by CodingIsNotEasy, over 7 years ago:
Also, I forgot to mention what I'm trying to accomplish is a rhythm game that gives point based on how close you pressed the button at the "Target" area. Right now the notes are Random but plan on making them sync to a beat later on. Here is an example of something similar to what i want to make:
Youtube Link
]
Move actor up and down automatically
By Afrobotsigner, with 1 reply.
Replied to by danpost, over 7 years ago:
Afrobotsigner wrote...
I need to make my alien spaceship move up and down automatically without having to press any key. The movement needs to be continuous till the ship is shot down. I need to apply the setLocation method. What other code can I use?
You will need to track which direction the ship is currently moving. The speed is a constant and can be hard-coded or held in a field. The new y-coordinate of the ship in your
setLocation
line can then be expressed as 'getY()+dir*speed' or 'getY()+dir*5', for example. The 'dir' field, as an int, would hold a value of '1' or
Ninja is a meme on fortnite battle royale
By xxxAli-Axxx, with 13 replies.
Last reply by davmac, over 7 years ago:
No spamming the forum please. Accounts will be disabled if it continues.
help me to complete this scenarios
By Rio, with no replies.
hei, i have some problem. I want make some scene, and the scene is if the object not collect at all, it'll show the dialog. Help me to fix this problem. thx
Need help with switching images when 2 objects intersect
By ananyagarg, with 9 replies.
Last reply by danpost, over 7 years ago:
ananyagarg wrote...
I am still unable to change the photos once the second bullet hits because when the first bullet hits, he barrier disappears. << Codes Omitted >>
That is because the bullet is not being removed when hitting a barrier. In the
Bullet
class
hitBarrrier
method (as last shown), add after line 4: <Code Omitted>
Help with keeping score.
By Astrooocow, with 2 replies.
Last reply by Astrooocow, over 7 years ago:
Thank you so much! I completely missed that. :) It works as expected now!
236
237
238
239
240
241
242
X