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
Is there an alternative to setLocation that uses the type double?
By byNici, with 1 reply.
Replied to by danpost, almost 6 years ago:
byNici wrote...
Is there an alternative to setLocation that uses the type double?
There is not -- at least, not among the methods given in the
greenfoot
package. However, that does not preclude you from making one yourself; or from importing a class that does have one. The
SmoothMover
class has a s
etLocation(double, double)
method. Use the menu bar commands "
Edit >> Import class ...
" and select it. Then have your
Actor
subclass extend it. You will then have to modify your code to make use of it.
How to make a "death counter"
By whoisKiwiKoala, with 1 reply.
Replied to by danpost, almost 6 years ago:
You will need a
static
field. However, because of the scope applied to static fields (they do not reset upon resetting the scenario), you will need to be able to distinguish between worlds instances that start a game (initial ones) from those that do not (subsequent ones). The best way to accomplish that is by giving your worlds multiple constuctors -- a non-parameterized one for initial worlds and a parameterized one for subsequent worlds:
java.io.IOException Stream Closed
By ranacoder96, with 1 reply.
Replied to by danpost, almost 6 years ago:
You cannot "steal" the standard input stream (
FileDescriptor.in
) from greenfoot, which uses it for the
Greenfoot
class methods
getKey
,
ask
and
isKeyDown
. The same may be true for
stdout
. Use
Greenfoot.as
k for user keyboard input of character strings and
System.out.print
or
println
for output.
hi, how do I run my ball image using jbutton arrow and players img using keyarrows the panel1 is set in Grid layout .(java eclipse)
By Taeyo, with 8 replies.
Last reply by danpost, almost 6 years ago:
Taeyo wrote...
the code page is error
Try
this
.
Rotate a „GreenfootImage“
By RcCookie, with 2 replies.
Last reply by RcCookie, almost 6 years ago:
Oops.. must have missed that method. Thanks anyways!
Lag
By Roshan123, with 20 replies.
Last reply by Roshan123, almost 6 years ago:
hey danpost, thanks a lot for the helping and suggesting me now it's not lagging anymore i think the problem was with the draw Oval, fill oval, setColor(rand color) when i changed it to a static image of the shield then it was not lagging anymore
Could u help 3 question scenario
By Sauravbasyalking12, with 1 reply.
Replied to by danpost, almost 6 years ago:
Please refer to
this page
of the Java tutorials.
How to create levels of a game?
By ShauryaThapan, with 2 replies.
Last reply by danpost, almost 6 years ago:
Oftentimes, the inclusion of
static
fields (class variables) in your
MyWorld
class is sufficient to allow the game to become more difficult from one world instance to the next. Some
static final
fields (class constants) can be used to describe the initial set-up of a "level". One
static
field (variable) would be used to track which level is current.
Acceleration, Collision and and Walljumps?
By Pumk!n, with 2 replies.
Last reply by RcCookie, almost 6 years ago:
To actually implement the moving system, you need to save your speed from frame to frame:
Methods and method signatures
By Ojhayvee, with 1 reply.
Replied to by danpost, almost 6 years ago:
Ojhayvee wrote...
What would be the method signatures for; 1. setLocation(); 2. getX(); 3. getY();
An example is given in the first section of
this
page of the java tutorials.
Not able to create a score counter
By Coder12341234, with 5 replies.
Last reply by danpost, almost 6 years ago:
The problem is that you have two (2) methods that could potentially remove the actor from the world, you call them unconditionally and they both require that the actor be in the world when called. You could use an if statement to place the condition of the second calling that the actor be in the world, as such: <Code Omitted>However, if you decide to rearrange things, it may cause issues again. Better, would be to start both methods,
removeEnemy
and
hitByProjectile
, with the following line:
Need help with WBC-4 chapter 5 Greenfoot Homework!
By TheHDMICord, with 2 replies.
Last reply by TheHDMICord, almost 6 years ago:
That seems to have fixed the issue! Thank you so much danpost, you're an absolute lifesaver!
Why is this spawning in before I press "f"?
By Pumk!n, with 2 replies.
Last reply by Pumk!n, almost 6 years ago:
thank you so much, I am pretty new to this, so thanks
How can i change the background during game
By alicia007, with 1 reply.
Replied to by danpost, almost 6 years ago:
alicia007 wrote...
i want to change the background during my game at a specific action.
Use this
setBackground
method or this
setBackground
method.
Newton's Lab: this(new Vector()) what does this mean??
By disassociated, with 5 replies.
Last reply by danpost, almost 6 years ago:
disassociated wrote...
Can you open that up or give a hint about the concept where I can read more? The run sequence is like this right? Space/ Constructor Vector / Constructor SmoothMover / Constructor Body / Constructor
Let me just point out a thing here. When an
Object
instance is created, it is created from the bottom up. All extending classes are built on their supers. So, when you create a body, the
SmoothMover
portion is created before the
Body
portion. Think of it as such that the
Body
object inherits pre-defined traits provided by the
Smo
112
113
114
115
116
117
118
X