This site requires JavaScript, please enable it in your browser!

What is happening right now?


reply to How do i get an image to point the way it is moving?

By Alwin_Gerrits - 22 minutes ago
Obviously you can allso change the image to a mirrored one. You'll just have to put it instead of the getImage line.
We thought the same dan :). I just didn't write it down. But that put aside, I see how your code is better :).

reply to Start/Stop Music when world is getting loaded.

By danpost - 19 minutes ago
DerPonyFreund wrote...
But how do I detect when a button is pushed or not?
You already have instance fields for each button; however, they should not be named the same as the class that created them (at least not exactly, case-wise). In other words, you should have something like this for lines 12 through 14: <Code Omitted>These actors, 'newGame', 'options' and 'credits', should be checked for clicks on them just as you have tried in your 'worldChanges' method by using those field names (field names do not go inside double-quotes like String objects do). This code should, however, either be in the 'act' method or a method that is called by the act method: <Code Omitted>Since all three buttons will result in a new world object being created and set active, you could create a local variable to hold the world to go to before checking for clicks: <Code Omitted>and if a button was found clicked (for the '// do whatever's) set 'nextWorld' to a newly created world of the required type: <Code Omitted>After this, you can check for a value in 'nextWorld' other than 'null' and set the world active (there is no reason to set booleans and other fields to proceed at a later time from a different method -- as soon as something is found needed to be done, do it; this will simplify your code and make it easier to understand). <Code Omitted>Calling 'stopped' does not in itself stop the running of the scenario ('stopped' is called from within greenfoot itself as a response to when the scenario is paused while an world instance of this class is active). You can do other things as well within this final 'if' block; such as passing field values or objects to the new world instance, adjusting the background of the new world instance, or even calling methods on the new world object or on any other object contained within its scope.

reply to World Isn't Spawning New Actors

By BryanGSMST - about 3 hours ago
danpost wrote...
Line 18 is setting the value of 'j' to zero; so the condition in your next line, line 20, will always be 'false' ('j' will never be anything but zero). Declare 'j' outside of the method, changing it from a local variable to a instance field (a local variable exists until the method is exited, so the next time the method is executed the variable is re-created; an instance field exists as long as the object it belongs to exists -- in this case, your CrabWorld instance, or world object). After moving the line outside the method, you will need to reset the field to zero after ten is reached. So, add a line to reset it back to zero when you add a new Bread object into the world. You may also want to increase the limit from ten -- at that limit, you will end up with an over-abundance of bread in your world very rapidly.
Thanks so much! :)

reply to Invincibility?

By CKnox - about 7 hours ago
Thankyou Hippo, it works now!