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

2014/1/7

Cannot find symbol - variable count

Moynzy Moynzy

2014/1/7

#
 public void CheckGoal()
    {


        if (getX() + getImage().getWidth() / 2 > areaLeft && getX() - getImage().getWidth() / 2 < areaRight && getY() + getImage().getHeight() / 2 > areaTop && getY() - getImage().getHeight() / 2 < areaBottom)    
        setLocation(getX() + 400, getY()); 
        pitch spaceWorld = (pitch) getWorld();
        Counter counter = spaceWorld.getCounter();
        counter.bumpCount(1);
        
        count++;
        myLabel.setText("Score: " + count);
        
    }
Hey guys, where did i go wrong?
Moynzy Moynzy

2014/1/7

#
Please, anyone?
bourne bourne

2014/1/7

#
I'm not understanding the point of having both of these: counter.bumpCount(1); count++; Can you do something like the following (not sure what methods available from Counter): ... counter.bumpCount(1); myLabel.setText("Score: " + counter.getCount());
Moynzy Moynzy

2014/1/7

#
public void act() 
    {
        playerHitIt();
        BoundriesBouncey();
        CheckCollisionWithMarker();
        CheckCollisionWithDef();
        CheckGoal();
        Dribble();

    }
    
    public void CheckGoal()
    {


        if (getX() + getImage().getWidth() / 2 > areaLeft && getX() - getImage().getWidth() / 2 < areaRight && getY() + getImage().getHeight() / 2 > areaTop && getY() - getImage().getHeight() / 2 < areaBottom)    
        setLocation(getX() + 400, getY()); 
        up();
       
      
    }
    
    public void up()
    {
         pitch spaceWorld = (pitch) getWorld();
        Counter counter = spaceWorld.getCounter();
        counter.bumpCount(1);
    }
This is the problem, i have stayed with this. But when i press act, the score increases when the ball does not go in the area.
bourne bourne

2014/1/7

#
You are missing brackets:
if (getX() + getImage().getWidth() / 2 > areaLeft && getX() - getImage().getWidth() / 2 < areaRight && getY() + getImage().getHeight() / 2 > areaTop && getY() - getImage().getHeight() / 2 < areaBottom)
{
        setLocation(getX() + 400, getY());   
        up();
}
Moynzy Moynzy

2014/1/7

#
YOU ARE AMAZING AND PERFECT!! If there's anything I can do in return, please do ask! THANK YOU! SO MUCH!
You need to login to post a reply.