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

What is happening right now?

dammnn

Scoreboard not working

By dammnn, with no replies.
I want to increase the Scoreboard if my Actor shoots an enemy. It doesn't work, here are my codes: First, the world: public class Level1 extends World { Scoreboard scoreboard = new Scoreboard(); public Level1() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super(1000, 600, 1); populateWorld(); scoreboard = new Scoreboard(); } public void populateWorld() { addObject(new Mario(), 900, 100); for(int i = 0; i < 10; i++) { addObject(new Pilz(), Greenfoot.getRandomNumber(700), Greenfoot.getRandomNumber(600)); } for(int i = 0; i < 4; i++) { addObject(new Shyguy(), Greenfoot.getRandomNumber(500), Greenfoot.getRandomNumber(600)); } addObject(new Scoreboard(), 50, 20); } public Scoreboard getScoreboard() { return scoreboard; } } the Actor Scoreboard: public class Scoreboard extends Actor { private int score = 0; public void updateImage() { setImage(new GreenfootImage("Score: "+score, 25, Color.WHITE, new Color(0,0,0,0))); } public Scoreboard() { updateImage(); } public void addScore() { score++; updateImage(); } } and the Fireball Actor, which kills the enemy: public class Feuerball extends Actor { public int Scoreboard = 0; public void act() { move(12); if (isTouching(Shyguy.class) || isTouching(Shyguy2.class)) { ((Level1)getWorld()).getScoreboard().addScore(); removeTouching(Shyguy.class); removeTouching(Shyguy2.class); getWorld().removeObject(this); // Greenfoot.playSound(_soundFile_) } else if (isAtEdge()) getWorld().removeObject(this); } } can anybody find the prob?
Abwatts

reply to Prevent different objects from completely overlapping with each other

By Abwatts - about 5 hours ago
Thanks once again! For some reason, I can't really get the timer method to work properly, am I doing something wrong? Is there a way to use this code without inserting it into the act() method? <Code Omitted>
danpost

reply to How to instantiate a new world object

By danpost - about 7 hours ago
TNesler wrote...
when I run my program, I do not see my Colorpatch object on the background...:-(
Ahh -- you must have a black background. Okay, set the color to something else: <Code Omitted>