I got another problem when I was typing that long long ago but nothing happens when I eat all my food, not even one point. Can someone help me? (a different game)
public void score(){
Actor label = getOneObjectAtOffset(0,0, Label.class);
GreenfootImage img = new GreenfootImage (100, 30);
img.drawString(String.valueOf(leavesEaten), 2, 20);
setImage(img);
}
When the wombat eats a leaf, it turns to a number and it continues to move. I need the counter to stay on top of the wombat image. Not replace it.
When the wombat eats a leaf, it turns to a number and it continues to move. I need the counter to stay on top of the wombat image. Not replace it.
A reference variable for a Label object is created and assigned a value in the first line. However, nothing is done with this label within the method.
If you do not want to replace the image of the wombat, then do not use 'this.setImage' (equivalent to 'setImage'). If it is the label you wish to set the image to, then use 'label.setImage'.
When the wombat eats a leaf, it turns to a number and it continues to move. I need the counter to stay on top of the wombat image. Not replace it.
A reference variable for a Label object is created and assigned a value in the first line. However, nothing is done with this label within the method.
If you do not want to replace the image of the wombat, then do not use 'this.setImage' (equivalent to 'setImage'). If it is the label you wish to set the image to, then use 'label.setImage'.
For some reason, adding 'label.setImage' causes my game to stop. Nothing changes and no count is displayed.
For some reason, adding 'label.setImage' causes my game to stop. Nothing changes and no count is displayed.
What do you mean by stop? are you getting an error message? if so, what is it? which line is it stopping at?
What is the new updated code you are using?