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
I want my actor to let go of another actor after a certain time frame
By KCee, with 15 replies.
Last reply by danpost, 2 months ago:
Spock47 wrote...
That would be a possibility, too. But in that case, the poison cloud would only go after villagers, but not other pedestrians.
You are right. Might be better to have an (empty)
abstract grabPedestrian
method in the
Grabber
class and have each sub-type deal with their own specific behavior. If it is their specific behavior, then it makes sense to have the code in their specific classes.
how to find nearest object.
By envxity, with 1 reply.
Replied to by danpost, 2 months ago:
envxity wrote...
so dan with the auto fire it works but not as intendid so it does fire out but it fires out like 2-3 strands of bullets at the same time and i dont want that and it also didnt turn the player to face where it was shooting. so i figured that i would have to use the getobjects in range function but i cant figure out how to do it here is the code: << Code Omitted >>
Try this:
My Demon class has a NullPointerException when spawning into the world
By KCee, with 3 replies.
Last reply by Spock47, 2 months ago:
KCee wrote...
Thanks that worked! Theres a small problem now the blood demon isnt removing the villager from the world on contact, instead its just going up to it, then spinning in circles?
Seems to me that "getOneObjectAtOffset((int)speed + getImage().getWidth()/2, 0, Pedestrian.class);" is only working correctly if the demon meets the pedestrian's center exactly? Try with "getOneIntersectingObject(Pedestrian.class);":
NullPointerException in Grabber Class
By KCee, with 1 reply.
Replied to by Spock47, 2 months ago:
KCee wrote...
<Code Omitted>
grabbed can be null there, so replace the quoted lines with this (it moves the relevant line into the part where grabbed is checked to not be null):
how to reload
By envxity, with 4 replies.
Last reply by danpost, 2 months ago:
envxity wrote...
and i have another question how would i have a display that would show how much ammo you have left out of the starting amount of ammo
Please refer to my
Value Display Tutorial
scenario.
Error with Zombies
By RandomGuy, with 4 replies.
Last reply by envxity, 2 months ago:
fr
how to change an actors color
By envxity, with 13 replies.
Last reply by danpost, 2 months ago:
envxity wrote...
i keep on getting a null pointer exception for the turn towards mouse how do i fix it?
Try this then: <Code Omitted>
i dont want it to only turn towards the mouse when i click i want it to always follow my mouse if the button is gre
How would I make an actor grab another actor and drag them off the screen?
By KCee, with 9 replies.
Last reply by danpost, 2 months ago:
KCee wrote...
I cant make it "private void checkHitPedestrian()" because the checkHitPedestrian method is in my vehicle superclass as a boolean which my monster class is under. << Codes Omitted >>
Then use this for the method:
I want all actors under my Vehicle superclass to speedup during an event
By KCee, with 4 replies.
Last reply by envxity, 2 months ago:
o im sorry i didnt help :(
How do I make an actor turn into a frog upon contact with another actor
By KCee, with 1 reply.
Replied to by danpost, 3 months ago:
KCee wrote...
i have two actors under the same superclass "Pedestrian". One of the actors is called villager and I want him to turn into a frog upon contact with the other actor called "EvilWitch". << Codes Omitted >>
Looks like you have code in the
Villager
class to do just that. Only problem is that if contact with
EvilWitch
is more than one
act
step, which is most probably the case, then the image will be made smaller multiple times; and, at some point, it will try to make it a size that is zero or less, causing an error. You need a way to check whether the a
Use a variable in all classes
By gijsdevries, with 1 reply.
Replied to by danpost, 3 months ago:
gijsdevries wrote...
Im making a game where you can score points when a bullet hits a monster. I also want to make a scoreboard but I cant use the variable I made for points in the scoreboard class. I already tried to make the variable public but that doesnt work. A video or an example code would be sufficient. Im kinda new to this so keep the code as simple as possible please :)
Please refer to my
Value Display Tutorial
scenario.
I need the bullet to follow my mouse
By gijsdevries, with 3 replies.
Last reply by danpost, 3 months ago:
gijsdevries wrote...
Could you maybe give an example? right now I have this. The bullet only spawns at the coordinates of the mouse (a kogel means a bullet). << Code Omitted >>
I think all you need do is: <Code Omitted>Note that if your bullet moves too slow (less than maybe 5 pixels per move), the aiming will not be accurate -- maybe so inaccurate that it looks totally off. For the extreme example, if moving only 1 pixel per move, the movement will either be horizontal or vertical;
I want my villager subclass to change into a different image when touched
By KCee, with 1 reply.
Replied to by danpost, 3 months ago:
Doesn't the
rooted
method get called when a
Villager
instance is touched by a
RootedCorpse
object? Change its image there.
can anyone explain how to code ai in a way that my pea brain will understand?
By acredb, with 1 reply.
Replied to by danpost, 3 months ago:
acredb wrote...
basically i'm really stupid and can barely understand the syntax errors that i'm getting. << Code Omitted >> and if i try to fix one syntax error, another pops up, and so on no clue how to fix it, been on someone else's thread and i could barely read what was on the screen, everything kinda blurs together
The
Greenfoot.start()
method has a
void
return type. You cannot reference a
void
or compare it with anything. Also, the equal comparison operator is a double equal sign ( == ), not a single one ( = ).
How to add actors in the same place as before
By RandomGuy, with 2 replies.
Last reply by RandomGuy, 3 months ago:
Dude thank you so much!
2
3
4
5
6
7
8
X