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

GUARDIAN-X's Comments

Back to GUARDIAN-X's profile

import greenfoot.*; import java.awt.Color; public class Counter extends Actor { private int totalCount = 0; public Counter() { setImage(new GreenfootImage("Score: 0", 50, Color.WHITE, Color.BLACK)); } public void bumpSet(int amount) { totalCount = amount; setImage(new GreenfootImage("Score: " + totalCount, 50, Color.WHITE, Color.BLACK)); } public void bumpCount(int amount) { totalCount += amount; setImage(new GreenfootImage("" + totalCount, 50, Color.WHITE, Color.BLACK)); } }
that isn't the right code, give me a moment...
Danpost I am still having issues with the code you gave me. To give you a little more input on the way the score counter code looks, its like this, only its on a different world. But im trying to pass the same code to the Gameover world. here is the score counter code on the main Space world: [code]private void addAsteroids(int count) { for(int i = 0; i < count; i++) { int x = Greenfoot.getRandomNumber(getWidth()/2); int y = Greenfoot.getRandomNumber(getHeight()/2); addObject(new Asteroid(), x, y); } } private void addUFOs(int count) { for(int i = 0; i < count; i++) { int x = Greenfoot.getRandomNumber(getWidth()/2); int y = Greenfoot.getRandomNumber(getHeight()/2); addObject(new Asteroid(), x, y); } }[/code]
Your browser is ignoring the <APPLET> tag. What does this mean and how do I fix? Someone kindly explain. Thanks!
Thanks for the help! I will implement this in my next update!
I have a question. On the Gameover screen, how do I get the score counter to carry over from the main Space world to the Gameover screen without resetting to "0"?