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

2017/1/23

Bouncing Ball

KyrenD2 KyrenD2

2017/1/23

#
I need help! I am doing a project that I have to bounce a ball and keep track of the score when it hits the edge of the world but I don't know how to keep track of the score when it hits the edge of the world.Can anyone help me with the code?
Super_Hippo Super_Hippo

2017/1/23

#
private int edgeCount = 0;

//in act
if (atEdge())
{
    //...
    edgeCount++;
}
Nosson1459 Nosson1459

2017/1/24

#
Super_Hippo wrote...
private int edgeCount = 0;

//in act
if (atEdge())
{
    //...
    edgeCount++;
}
It would have to be:
private int edgeCount = 0;

//in act
if (isAtEdge())
{
    //...
    edgeCount++;
}
Super_Hippo Super_Hippo

2017/1/24

#
Oh yes, you are right, thank you. I probably missed that because I have never used that method myself... or because the method in the Animal class is named atWorldEdge.
You need to login to post a reply.