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

2012/11/27

help

BradH BradH

2012/11/27

#
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class GoodCastle here. * * @author (BradH) * @version (a version number or a date) */ public class GoodCastle extends GoodTroops {//time goes by as you gain money private int moremoney = 100; //assign counter private Counter counter; public GoodCastle(Counter pointCounter) { counter = pointCounter; } /** * Act - do whatever the GoodCastle wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { //as time goes by points will be added moremoney -- ; if(moremoney == 0) { Counter.add(5); } } } This is my GoodCastle class I have a counter in my game and i want the counter to gain 5 points everytime "100;" goes by, but the error reads as follows non-static method add(int) cannot be referenced from a static context. So I think I need a new method to tell some sort of time so the counter.add(5) will not come up with this error.
danpost danpost

2012/11/27

#
You are trying to add 5 to the class and not the counter.. Instead of
Counter.add(5);
try
counter.add(5);
BradH BradH

2012/11/27

#
ahhh, thanks just a simple error.
You need to login to post a reply.