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

2015/1/13

score counter not working for me

Dan123 Dan123

2015/1/13

#
code for counter: int count = 0; {if (balloon !=null ) { getWorld().removeObject(balloon); count++; example EXAMPLE = new example(); } act(); { getWorld().addObject(example) ; } //Create a new class, example act(); { setImage((new GreenfootImage("Counter : " + count,50,Color.GREEN,new Color(0,0,0,0)))); } } } ; }
xFabi xFabi

2015/1/13

#
act();
{
 
          getWorld().addObject(example) ;
}

where's your counter method ?
 public void counter()
{
            if (balloon !=null ) 
         
        {   
            getWorld().removeObject(balloon);
            count++;
            example EXAMPLE = new example();
        }
}
act();
{
          counter();
          getWorld().addObject(example) ;
}
Dan123 Dan123

2015/1/13

#
whats my "counter method"?
xFabi xFabi

2015/1/13

#
the method thats supposed to "count" You didnt include anything into your act() method that could do that, so how can you expect the programm to do it :)? The code above should work Edit: change act() to
public void act()
Also you didnt declare the actor, in the code given. If you didnt already do, write this in front of the if
Actor balloon = getOneIntersectingObject(balloon.class)
Oh, and please stop creating new topics, the context is lost, and its confusing,
You need to login to post a reply.