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
Null Pointer Exception Issue
By Tommy99, with 1 reply.
Replied to by davmac, over 12 years ago:
Please
use code tags
when you post your code, so that we can refer to the code by line number and copy/paste it easily. You're getting a NullPointerException on this line in the Home class: <Code Omitted> The reason is, you are calling 'getWorld()' before the object has been added into the world; it therefore returns null, and when you then call getWidth() this gives an exception. You need to postpone calling getWorld().getWidth() until after the object has been added t
help with random spawn
By nc-munk, with no replies.
I am making a game for a school project. I need help a random spawn function it is should spawn an asteroid in top for the screen and move down and i cant make them spawn and move my code look in line 27 to 42<Code Omitted>
enemy not spawning
By GamesGrinder1998, with 1 reply.
Replied to by GamesGrinder1998, over 12 years ago:
the code doesn't seem to work for here...
slow game
By poon, with no replies.
Hello i'm making a game for my object oriented programming class , i have a world with a scroll based on a project named "Scrolling Man" . that´s the code for the scroll : public void scroll(int cX, int cY) { x = x +cX; y = y +cY; getBackground().drawImage(Background,x, y); } the method is called when an arrow is pressed and it works, but i have a problem. the method makes very slow my game, i tried to reduce the size of the background but that no solves the problem, i removed the method call, and the game have not more lag. Please help me, how can i make the scroll without lag???
Help for Bomb Power-UP
By Neymar.Jr, with 39 replies.
Last reply by danpost, over 12 years ago:
On line 13, you have to use this: <Code Omitted>as line 11 causes 'getWorld' to return a 'null' value.
How to avoid adding objects on top of others
By gamer121, with 1 reply.
Replied to by danpost, over 12 years ago:
Replace the last two lines of code posted with this: <Code Omitted>
Removing Bomb and Bad when they intersect
By akilino, with 9 replies.
Last reply by akilino, over 12 years ago:
davmac wrote...
Please, use code tags when you post code. I gave a link explaining how to do this earlier. It makes it so much easier to point out parts of your code (discuss the line numbers) and also to copy-and-paste your code.
Sorry davmac, I thought that what you wanted to say with that, to understand better the code, was the comment. Now I noticed that it is to present the code in a better way to understand. My apologies.
Adding multiple objects to the world after an intersection
By gamer121, with 1 reply.
Replied to by bourne, over 12 years ago:
Use a loop like the following: <Code Omitted>
Enemies code not working
By GamesGrinder1998, with 6 replies.
Last reply by erdelf, over 12 years ago:
did u even change something `? this should work line 68-71 <Code Omitted>
Variables keeping track of values
By gamer121, with 28 replies.
Last reply by gamer121, over 12 years ago:
Nevermind, I finally got it to work! Thanks for all of your time and help. I really appreciate it!
Changing locations of objects after an intersection
By gamer121, with 3 replies.
Last reply by gamer121, over 12 years ago:
So now, I want to add 10 new food objects into the world randomly every time the Player gets to Home. How do I add the food randomly without copy and pasting the code several times? My Food class code is shown below. Thanks so much for the help.
Selecting an actor using Greenfoot.mousePressed(this)
By Zzimon, with no replies.
Trying this again, what I'm trying to do is select an actor after clicking it so that when i have clicked an actor i can press w,a,s or d to get my actor to move either up, down, left or right and after the actor have moved for it to become un-selected again. I have tried this a couple of different ways and haven't been able to get any of them to work, actually if I could just get one tile to move in a direction when i click on it i would be thrilled but I can't. here's a picture of what my world looks like: <Image Omitted> The blue background is made from me using a class that creates a mini-world withing a world so as to get the grid working. I suspect that there is something in my PIP actor or my world actor that is blocking the mousePressed on each of the tile actors and making it click on the PIP element instead and I can't quite figure out which thing in my code that might be causing this. World actor: <Code Omitted>PIP actor: <Code Omitted>and the tile actor with the selection/move script aka my Sword actor <Code Omitted>
Issue with switch
By theiam79, with 4 replies.
Last reply by theiam79, over 12 years ago:
Figured it out. Simple ordering, respawn before removing the old asteroids (duh). What happens when two collide is the picture changes, for effect, a new asteroid respawns 10 pixels in from the left at a random height, and then the two old asteroids disappear.
UserInfo.getTop(10)
By karolis, with 2 replies.
Last reply by davmac, over 12 years ago:
You just need to loop through the users (the list returned by UserInfo.getTop(...)), and print their name and score.
Creating a grid in a non-grid world
By Zzimon, with 89 replies.
Last reply by Zzimon, over 12 years ago:
I don't quite understand what you mean with the Actor field, could you give an example of how to use it?
693
694
695
696
697
698
699
X