So im making a kind of very simple space invaders but im trying to add a score board thing I used the: Edit, import class then counter. And when i have put it into my code to add a score every time my enemy dies it would work however when i put ontop of my code it doesnt work:
Here is my full code for my bullet
Pls help
public static int actCounter = 0;
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) public static int actCounter = 0; /** * Write a description of class bullet here. * * @author (your name) * @version (a version number or a date) */ public class bullet extends Actor { /** * Act - do whatever the bullet wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public static int actCounter = 0; public void act() { move(3); isTouching(); if (isAtEdge()) getWorld().removeObject(this); } public void isTouching() { if (isTouching (alien2.class)) { removeTouching(alien2.class); actCounter.setValue(actCounter.getValue() + 1); } { if (isTouching (alien.class)) { removeTouching(alien.class); actCounter.setValue(actCounter.getValue() + 1); } if (isTouching (laseralien.class)) { removeTouching(laseralien.class); actCounter.setValue(actCounter.getValue() + 1); } if (isTouching (laseralien2.class)) { removeTouching(laseralien2.class); actCounter.setValue(actCounter.getValue() + 1); } } } }