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
how to stop car actors if there is already a car actor moving through a crossroad
By Rayray, with 2 replies.
Last reply by Rayray, over 11 years ago:
thanks!
Scrolling Background
By Jellyfish, with 16 replies.
Last reply by danpost, over 11 years ago:
Jellyfish wrote...
@danpost I want to make my actor be the center of the screen at all times. How can I edit this code in the FatCat class to do that?
The FatCat class does not need editing to perform the scrolling. Scrolling is much bigger than just the central character. It is something that encompasses the entire world (the background of the world AND all actors in that world that are allowed to scroll). Scrolling should done through process either performed in the world act method or in a method it calls. I created several fairly simple scroll support classes that can be used
Adding clock
By Ankit_Thapa, with 5 replies.
Last reply by danpost, over 11 years ago:
Ankit_Thapa wrote...
Basically I want to start the timer whenever the user press the run button. I want to display the timer till the game ends
"Basically" is not enough. You need to be detailed and explicit; and provide all aspects of how you want it.
calculate distance from one object to another?
By h123n, with 4 replies.
Last reply by danpost, over 11 years ago:
I cannot see how the code in the NPC class could possibly do what you want at all times. Also, if you are running (or, if you have) an 'act' method in your Guard class, then it would override the one in the NPC class; in other words, both will not run 'at the same time' unless you call 'super.act();' from the Guard class within the 'act' method or a method it calls. Actually, I cannot be sure that the best place for the 'follow' method is in the NPC class. Do you have other NPC subclasses that will be calling that method or is Guard the only one? Also, instead of 'looking' for the Toby
Enquiry
By Abanourmo, with 1 reply.
Replied to by danpost, over 11 years ago:
The question is: how little would you be willing to get paid for creating said software?
Problem with sound, play() doesnt wait for sound to finish to start again.
By ziLaK, with 11 replies.
Last reply by pitrang, over 11 years ago:
sorry, wrong room...
SnakeGame Growing Snake
By ZOE, with 14 replies.
Last reply by ZOE, over 11 years ago:
I need to thanks you a lot for helping but i found the problem and my snake now is growing!!! Thank you!
If Actor Clicked
By LamboCreeper, with 1 reply.
Replied to by Super_Hippo, over 11 years ago:
<Code Omitted> 'mouseClicked' returns true if the mouse was pressed on the object and released afterwards. 'mousePressed' returns true when the mouse was pressed on the object. You can use this in a class code. Then 'this' is the object of the class in which this code is executed. Instead of 'this', you can also use 'null' (any click (like descripted above) returns true) or a reference to an actor (
not
a class). If you use 'this' in a world subclass, it returns true if the clic
Making game interesting
By Ankit_Thapa, with 5 replies.
Last reply by Super_Hippo, over 11 years ago:
For balloons, you could add them like this: <Code Omitted>This adds ten balloons at the bottom outside the world. To make this possible, you have to create the world with 'super(x,y,cellsize,false)'. This will make it possible for object to be outside the visible world. If you want to have this code in a world subclass, just remove all 'getWorld().' The Balloon code could look like this:
Saving and loading
By ninjasperm99, with 6 replies.
Last reply by ninjasperm99, over 11 years ago:
like how do i access it while the code is running do i need to make a button for it or right click etc?
Help- Simple Timer
By Leenza, with 3 replies.
Last reply by danpost, over 11 years ago:
A game timer can work in one of two ways -- it can track actual time or it can track game act cycles (frames). Either way, you will need an instance field of int type in your world subclass. If tracking frames, the act method of that class should increment the value of the field unconditionally, then check its value for game limit (usually, scenarios run between 50 and 60 frames per second; so, for example, a two-minute game would be limited to between 6000 and 7200 acts).
question about placing objects!
By veyydot, with 2 replies.
Last reply by Super_Hippo, over 11 years ago:
I think his only problem is that ALL pairs are next to each other (because he places them like that). If all cards would be placed randomly and some pairs are next to each other, this wouldn't be a problem.
Rollover button help
By Cytotoxin, with 2 replies.
Last reply by Cytotoxin, over 11 years ago:
Thank you very much danpost, you have helped me greatly.
Counter doesen't increase when item is collected
By SalatgurkenJoe, with 32 replies.
Last reply by danpost, over 11 years ago:
You could remove all the actors from the current world or set a different world active (to get to the same point of having an active world with no actors in it. If you have actors being added by way of your World subclass act method, setting a new World object active would be the way to go. At this point, you can work with the background image of the now current world as needed. The methods you might use are (1) if changing worlds, the Greenfoot class method 'setWorld'; (2) if removing actors, the World object methods 'getObjects' and 'removeObjects' (3) if setting a new background image
Changing Text size
By Leenza, with 3 replies.
Last reply by danpost, over 11 years ago:
Leenza wrote...
Where exactly would I put this code? Would I put it where I currently have < Code Omitted > or somewhere else (sorry I am a beginner)
Yes, it would replace those exact lines.
583
584
585
586
587
588
589
X