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
why setImage doesn't work?
By Actle, with 8 replies.
Last reply by Actle, almost 8 years ago:
danpost wrote...
Actle wrote...
how?I thought for a long time but couldn't come up with the answer.
Add a constructor to the class and initialize the zombies through code there. You will probably need a static int counter to track which zombie is being created:
game over image not displaying
By hmhmhn, with 4 replies.
Last reply by danpost, almost 8 years ago:
hmhmhn wrote...
my Gameover class does not have any code as im just using it as an image. before the delay the game will just reach 8 points, that will start the delay, during the delay of 2 seconds I want my gameover image to be shown on the screen and once the delat of two seconds is over the game will restart
You will need some code in your GameOver world. At least something to set a new PongWorld object active. The delay should probably be in that class also: <Code Omitted>
Identify an actor
By misg, with 1 reply.
Replied to by danpost, almost 8 years ago:
misg wrote...
how I can identify an actor? Let us assume there are 4 actors of the same in the world. How can I know and identify what is the 1,2,3 and the 4th of them? Is there a chance to have an activity if the actor is the actor number 2?
You could list them or give each a unique state; otherwise they would not be essentially identifiable. There may still be a way that could work; but it is not guaranteed to work in future versions of greenfoot. An undocumented behavior in the way greenfoot lists the actors that are placed into a world may be used to identify a specific actor.
Kaden this is for you
By Hitman735, with no replies.
<Code Omitted>
HEALTH COUNTER GOES DOWN WHEN MONSTER NOT TOUCH THE GUY
By ErnieBoi, with 5 replies.
Last reply by ErnieBoi, almost 8 years ago:
ˢᵒʳʳʸ ᵈᵃⁿᵖᵒˢᵗ ᵗʰᵃⁿᵏ ʸᵒᵘ ᶠᵒʳ ᵗʰᵉ ʰᵉˡᵖ ᶦ ᵃᵐ ᵉʳⁿᶦᵉ
How to end a game when a specific score is reached?
By hmhmhn, with 5 replies.
Last reply by danpost, almost 8 years ago:
hmhmhn wrote...
<< Code Omitted >> I just don't know how to make the game stop at 8 points, because ive used strings for the score im guessing I have to do it in an act method in the world class??
I am not sure what you mean by "ive used strings for the score". The
getValue
method of the
Counter
class returns an int value which is a score. Best places to check for game over is when you add to the scores (lines 47 and 53 of your PongWorld class).
Problems converting between greenfoot.Font and java.awt.Font
By tonyreks, with 1 reply.
Replied to by danpost, almost 8 years ago:
I came up with the following test class code which seems to work:
Adding a point to the score counter.
By lorcis__, with 3 replies.
Last reply by danpost, almost 8 years ago:
lorcis__ wrote...
The score counter has been added in the world "capworld" << Code Omitted >>
Okay -- as an alternative to the line previously given, you could use: <Code Omitted>
Greenfoot export jar empty window
By JustDylan, with no replies.
I've been trying to export my greenfoot game for about 3 hours but I can't get it to work.
github link
this is the github page if the game, I am working in an external ide so that's why I am able to work in packages. it also fully functions in greenfoot. I think greenfoot doesn't know what the default world is when you execute the exported jar because it creates an empty window. anyways, does somebody here know why this is happening. I am using version 3.1 btw, in the newer versions there is no good way of using an external ide.
How do you delete comments on a game?
By vinay365, with 2 replies.
Last reply by vinay365, almost 8 years ago:
Oh ok. Thanks for your help!
Int share between actors
By Nahquin, with 13 replies.
Last reply by Nahquin, almost 8 years ago:
Thank u very much.
Abstract World, Health Bar
By fittirc04, with 2 replies.
Last reply by danpost, almost 8 years ago:
A couple things about your code: (1) instead of a field and a
getter
method in each
Area World
class, you can simply add them into the
AbstractWorld
class and inheritance apply them to all
Area
worlds. The
getter
method itself is not actually needed at all, provided the field has
public
access. Also, by making the field
static
and only creating a
HealthBar
object in your initial
Area
world, all areas can use the same health bar: <Code Omitted>
justification in terms of why they are classes and why they are inheriting from actor or world
By Rodrigo_Pizarro, with 1 reply.
Replied to by danpost, almost 8 years ago:
Rodrigo_Pizarro wrote...
Can someone please help justifying classes and why they inheriting from actors. i would be very much appreciated. An example would more than enough so i can guide myself through thank you.
The
World
and
Actor
abstract classes are base classes for any and all worlds and actors. The greenfoot platform is built around these classes. You cannot create a world in greenfoot without a class that extends the
World
class and only
Actor
objects created from some extension of
Actor
are the only objects you can place into a
Upload
By Nahquin, with 2 replies.
Last reply by Nahquin, almost 8 years ago:
Thank u
Shopping Cart mouseClicked()
By adore.ange, with 1 reply.
Replied to by danpost, almost 8 years ago:
adore.ange wrote...
I'm not familiar with mouseClicked(). I have a shopping cart assignment which involves: The ShoppingCart (actor) will be a class with no image. The class will simulate purchasing the clicked on objects and required quantity. Must have Greenfoot.mouseClicked() and quantity = Integer.parseInt(Greenfoot.ask(Enter quantity:"); I have to be able to click the item image which is on the world and have it to let the player put in the quantity. Then have the number of items they inserted and the picture show on the world. << Code Omitted >>
The
mouseClicked
part look
226
227
228
229
230
231
232
X