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
Stop player from moving after intersecting actor
By comfortablyNumb, with 1 reply.
Replied to by danpost, over 6 years ago:
Never use thread ops in greenfoot -- and only use Greenfoot.delay when you want the entire scenario to pause for a specified amount of time. It would be better to have the player detect this actor and the
canMove
field should not be a
static
one. How can one tell whether a field should be
static
or not? Ask what happens if you have more than one instance of the class (two or more players, in your case). If the state (field value) is at all times the same for all instances, then you can make the field
static
. In your case, I doubt you would want all to not mov
Contact with transparent images
By PowerDj, with 7 replies.
Last reply by danpost, over 6 years ago:
PowerDj wrote...
Ah, I see what you mean here. I think it would be better to describe my problem with an image: << Image Link Omitted >> Basically, the red block has already been placed while the blue block is being controlled. I want to use color methods to check when the red block is underneath the blue block, which will prevent the blue block from being placed (obviously I could just use isTouching(), but I'm using the squares to get the hang of the color detection for other images). Getting colors from the background of the image only returns grey, so I need something that checks the color
get random value from array based on level
By comfortablyNumb, with 4 replies.
Last reply by Super_Hippo, over 6 years ago:
The equals method compares the characters/content in the string (true if they are the same), == is only true if they are both the same string (the same object). As a simple rule: Always use equals instead of == for strings. (Unless you actually want to check if it is the same object of course.)
Greenfoot Bug again? - NullpointerException
By ITStudent, with 1 reply.
Replied to by danpost, over 6 years ago:
You cannot call a method (
showText
-- on last line) on a non-existent object. The reference to a
World
object returned by
getWorld
will be
null
if
this
actor is removed from the world (previous line). Change last line to: <Code Omitted>
I need help with my code
By kahn, with 2 replies.
Last reply by kahn, over 6 years ago:
thx dadpost
Illegal State Exception: actor trying to get location of player when it has been removed from the world
By comfortablyNumb, with 6 replies.
Last reply by comfortablyNumb, over 6 years ago:
epico its working now :)
Greenfoot - Movement BUG?
By ITStudent, with 2 replies.
Last reply by ITStudent, over 6 years ago:
So i am using shift instead of q and now everything is working fine. Thank You.
Need help with Program Greenfoot #2. I have a question please assist.
By Waterfall100, with 1 reply.
Replied to by danpost, over 6 years ago:
Please provide code, error and location of error.
How do I remove another actor.
By AVH, with 1 reply.
Replied to by danpost, over 6 years ago:
AVH wrote...
I'm trying to kill an orc, by using key is down "space" to remove an orc and use an image when space is clicked. But it is not working.<< ,<< Code Omitted >>
If the orc is an intersecting object, then line 7 removes the wrong actor.
I need help adding a actor if another actor touches the edge!!!!!
By kahn, with 1 reply.
Replied to by kahn, over 6 years ago:
nvm figured it out
TowerDefense
By johnsonhwang1008, with 1 reply.
Replied to by Super_Hippo, over 6 years ago:
If you have a variable in your Enemy class which saves the traveled distance for the actor (increase it by its speed whenever it moves) and a method to return it … <Code Omitted>… then a tower can get the enemy in range with highest distance traveled and shoot a bullet in that direction:
About random populating
By Ethan_net, with 3 replies.
Last reply by danpost, over 6 years ago:
Ethan_net wrote...
Oh, and also only one marble exist for one y value.
Have the method,
addMarbles
, and add all the marbles in one calling. That is, move the loop from the constructor to the method. That way, the loop counter value can aid in controlling the y-coordinate value where the marbles are placed.
Flip a GIF image depending on which way you are going
By Hundmat, with 10 replies.
Last reply by danpost, over 6 years ago:
Hundmat wrote...
how do you create a gifimage array?
<Code Omitted>
Checking if the object is still there
By Erik27, with 1 reply.
Replied to by Nosson1459, over 6 years ago:
it would probably just be easier to add the new drone in the previous drone like this<Code Omitted>
How can I make a score counter ?
By BestMannCZ, with 1 reply.
Replied to by BestMannCZ, over 6 years ago:
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Vcela here. * * @author (your name) * @version (a version number or a date) */ public class Vcela extends Actor { /** * Act - do whatever the Vcela wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { if (Greenfoot.mouseClicked(this)) { ((Louka) getWorld()).smazVcely(); } } }
164
165
166
167
168
169
170
X