As an alternative, you could use the 'drawstring' method on the background image of the world. However, you will have to replace the background image each time the value of 'comida' changes (to remove the old string -- so you can draw the new one -- so you will not end up with string over top of string).
I think you need Greenfoot version 2.4 to use it. If you are not using the latest version, then you need to create an Actor subclass and set a Greenfoot image of the text you want to display to it. You will need a method to change the image when the value of 'comida' changes.
@alikhan, after reviewing the class myself, I realize that it may be quite complicated for you, as it is riddled with extra stuff that would not be needed in your case. You should probably attempt something (create your Tank, Turret, and Shot classes) and when you run into difficulties, start a new discussion thread for help, posting the code you tried, copy/pasting any error messages you may be getting, and describing your issue both in general and in detail, providing any and all possible pertinent information..
@alikhan, there are many scenarios on the site (some of mine included) that have examples of using mouse clicks to aim and fire shots from an object. My Global Defense scenario has cannons that aim and shoot by mouse actions, for example (and you can view the code of the Cannon class within the running of the scenario itself. Just do a search on 'Global Defense'.
You could use the extra condition (besides the door being clicked on) that no key object be in the world: if ( getWorld().getObjects(Key.class).isEmpty() && Greenfoot.mouseClicked(this) )
2014/11/15
BABYgame
2014/11/15
BABYgame
2014/11/15
BABYgame
2014/11/14
Ecosystem Simulator
2014/11/13
Mouse Click Game: Keys and Doors
2014/11/11
Tank Game
2014/11/11
Tank Game
2014/11/9
Mouse Click Game: Keys and Doors
2014/11/7
Extreme Greeps with Download