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
setLocation for other classes
By Quabey, with 1 reply.
Replied to by danpost, over 5 years ago:
Quabey wrote...
Hey, Im currently working on a small game and Im trying to reset the player after every round to his starting point. This code is in my commands class snake and turtle are both subclasses of commands << Code Omitted >> But it just doesn't work. Anyone here know how I can fix it.
Looks to me like lines 8 thru 11 (presuming "
actor1
", which looks undefined, should be "
snake
") are specific to the turtle and lines 4 thru 7 are specific to the snake and, therefore should be done in their specific classes (however, cross-collision checking should be avoided).
Illegal scenario
By Roshan123, with 2 replies.
Last reply by danpost, over 5 years ago:
Roshan123 wrote...
Danpost plz tell me that is he a hacker or its a problem with the website It shows that 6 users voted his scenario, but below the like button there is no user who voted his
scenario
Its the same guy whose
account
is disabled by greenfoot.org
Maybe more of a spammer than a hacker. Possibly all 6 users who voted were disabled. ?? (just a guess)
Can i do something like him or its illegal
Not something I would suggest doing, even if possible.
Is there an alternative to setLocation that uses the type double?
By byNici, with 1 reply.
Replied to by danpost, over 5 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, over 5 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, over 5 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, over 5 years ago:
Taeyo wrote...
the code page is error
Try
this
.
Rotate a „GreenfootImage“
By RcCookie, with 2 replies.
Last reply by RcCookie, over 5 years ago:
Oops.. must have missed that method. Thanks anyways!
Lag
By Roshan123, with 20 replies.
Last reply by Roshan123, over 5 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, over 5 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, over 5 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, over 5 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, over 5 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, over 5 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, over 5 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, over 5 years ago:
thank you so much, I am pretty new to this, so thanks
111
112
113
114
115
116
117
X