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
Casting
By SANELE, with 1 reply.
Replied to by danpost, almost 2 years ago:
SANELE wrote...
can someone please explain to me Casting with examples.
Let's say you had in your
MyWorld
class a method that you wanted to call from an
Actor
subclass. Maybe your character dies and you want the world to show a game over screen, so you want to call the
gameOver
method:
Code only execute on first instance
By Makuro, with 3 replies.
Last reply by danpost, almost 2 years ago:
Makuro wrote...
<< Codes Omitted >> Thanks for your reply and here are the Game Manager and Background class respectively
I really do not see the need of the
Game_Manager
class. All the information stored in fields there can be determined on the fly, with fair programming. A
Game_Over
class extending
Actor
could be used to show victory or failure and at the same time be used to stop the scenario when added into the world with (in
Game_Over
class): <Code Omitted>Instead of setting fields
Laggy Greenfoot
By Wiwhyweirdo, with 2 replies.
Last reply by danpost, almost 2 years ago:
Wiwhyweirdo wrote...
After some more testing I have noticed that whenever I receive damage the game speeds up at gets less laggy. Do what you want with this Information .
You might be doing something with images that is causing the lag issue. Make sure you pre-load your images. Make sure you always reference those pre-loaded images when setting an image. Keep your world at a reasonable size. I stick to not much more than (900, 600) world size (depending on the scenario). If using an unbounded world, make sure all actors are removed from the world after they leave the viewport
Greenfoot scenario freezing in browser
By epm, with no replies.
Hey, I tried to share my scenario but it keeps initialising. After a long time it loads but when changing the world it start freezing again. I really don't know why :( It is working in Greenfoot. You can find my scenario
here!
How to reset a World while the Program is running?
By Bankspeers, with 5 replies.
Last reply by Bankspeers, almost 2 years ago:
Thank you, now it works
How to detect if all objects are gone
By Psg, with 11 replies.
Last reply by danpost, almost 2 years ago:
Psg wrote...
hey, dan I need your help. I have a problem. I believe this if statement is working, but reading the wrong value of the integer rotate. What should i do
First, you should understand that the rotation is already being held in the Actor class, meaning you do not need to declare another field for it. You could use something like the following: <Code Omitted> It is not really clear by your code as to exactly what you are trying to achieve with the turn methods Obviously, you want the crab to turn sharp at an edge, whic
How to stop actors from "sliding" after calling the move() function and changing orientation
By TheGrrMan, with 5 replies.
Last reply by danpost, almost 2 years ago:
TheGrrMan wrote...
your QActor class, how do I access this?
It can be found in my
Asteroids w/Improved QActor class
scenario. Again, it is not to be modified in any way -- just used as is. Download the scenario and open in greenfoot. Then, you can copy/paste the class into your scenario. It does work differently than the
SmoothMover
class, however. Open the class and read through the instructions carefully.
Actor
subclasses requiring it should extend the
QActor
class.
How do you rotate an object to spawn in a different way?
By zlm, with 2 replies.
Last reply by zlm, almost 2 years ago:
Yes, thank you so much!
How do you make an object move along with another object
By jeremyneedshelp, with 1 reply.
Replied to by danpost, almost 2 years ago:
jeremyneedshelp wrote...
I cannot make my frog to move along with the boat that allow the frog to cross the river. i managed to get the frog to go on top of the boat but it wouldnt move at all. it would just get stuck on the boat and it would die.
You need to show your current codes for both the frog and the boat. Also, you can look at other codes that do similar things. For example, my
Jump and Run Demo w/Moving Platform
scenario has an independently moving actor moving on a platform.
Adding a method to superclass Actor directly
By ChristophT, with 2 replies.
Last reply by ChristophT, almost 2 years ago:
Thank you for your reply. At least I am not going to waste my time then. To bad, I can't do that however.
Gradually decrease and increasing speed
By lightbringer, with 4 replies.
Last reply by danpost, almost 2 years ago:
lightbringer wrote...
cap out in a particular value
<Code Omitted> or <Code Omitted>
Need to execute sound.stop() once a sound has played through once
By lilnasX, with 1 reply.
Replied to by danpost, almost 2 years ago:
lilnasX wrote...
I want the class to play through the wasted sound once, and then once it has finished playing play the gameOverBGM sound in a loop. However, the if statements condition is never met and the gameOverBGM line is never reached. I can't just input wasted.stop() after wasted.play otherwise the sound will not play through once and it will immediately play my gameOverBGM. need some advice, thanks. << Code Omitted >>
You cannot track the progress of the sound from the constructor of the class. Use the
act
method for this control. Also, line 22 is a bit redundant. T
Getting Neighbours with Certain Traits?
By Foofoo99, with 7 replies.
Last reply by Foofoo99, almost 2 years ago:
Thank you so so much danpost! You have worked wonders in the progression of my remake of Stratego and I wish you a good night. I will try to let you know when the game is done.
Remove an Object when actor touches another object
By beaverboii, with 1 reply.
Replied to by danpost, almost 2 years ago:
beaverboii wrote...
I want to remove a block when the main actor touches another block to open up a secret gateway in my game. Been trying to figure out how to do this for 4 class periods but my teacher and I don't know how to do it and the 15 yr old tutorials on YouTube don't help.
Best would probably be to have an
Actor
reference field in the
Block
class (or a special subclass of
Block
) to hold the
Block
object that special
Block
object is to remove. That way, when touched, it will know which one to remove.
Sending Information from one Actor to another
By Mordanto, with 1 reply.
Replied to by danpost, almost 2 years ago:
Mordanto wrote...
I want to create an explosion by changing an image in the missile, but the "Gegner" checks whether the missile has hit him or not. I have done this because the Gegner's hp is deducted for this. But now I have to somehow tell the rocket to change its magic. << Code Omitted >>
The following will call a
public
method that you can put in the
Rocket
class: <Code Omitted>
22
23
24
25
26
27
28
X