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

2017/1/15

breakout counter: add score each time ball hits bricks

beyondFrustrated beyondFrustrated

2017/1/15

#
i´m trying to set up a counter which will keep track of my score. i´ve watched joc but that only shows how you program scoring when the ball hits the paddle.I on the other hand am trying to program it so that i´ll get a point each time the ball hits a brick. can anyone help?
Super_Hippo Super_Hippo

2017/1/17

#
It could look a bit like this:
//in act method of the ball, after moving
if (isTouching(Brick.class))
{
    removeTouching(Brick.class);
    Counter c = (Counter) getWorld().getObjects(Counter.class).get(0);
    c.add(1);
}
beyondFrustrated beyondFrustrated

2017/1/19

#
thanks
You need to login to post a reply.