Im trying to get my "int antaltryk" to add 1 each time i click the "knap1" class, but it only works once, and then i cant press it anymore. What should i do? The .moneys has to be 10 or greater than, and when it gets to 10 again i cant press it
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) public class Knap1 extends DelayableActor { int antaltryk = 0; public void run() { tryk(); autoklik(); autoklik2(); tekst(); } public void tryk() { Knap1 knap1 = (Knap1)getWorld().getObjects(Knap1.class).get(0); World TurtleWorld; TurtleWorld = getWorld(); TurtleWorld space = (TurtleWorld)TurtleWorld; Counter counter = space.getCounter(); if(counter.moneys>=10 && Greenfoot.mousePressed(knap1)) { antaltryk++; counter.minusscore(); } } public void autoklik() { Knap1 knap1 = (Knap1)getWorld().getObjects(Knap1.class).get(0); World TurtleWorld; TurtleWorld = getWorld(); TurtleWorld space = (TurtleWorld)TurtleWorld; Counter counter = space.getCounter(); if(antaltryk==1) for(;;) { counter.moneys++; setDelayingTime(2000); break; } } public void autoklik2() { Knap1 knap1 = (Knap1)getWorld().getObjects(Knap1.class).get(0); World TurtleWorld; TurtleWorld = getWorld(); TurtleWorld space = (TurtleWorld)TurtleWorld; Counter counter = space.getCounter(); if(antaltryk==2) for(;;) { counter.moneys++; setDelayingTime(1000); break; } }