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

2017/3/6

help with my score board

I've already added a scoreboard, and when I click on the voidaddScore() on the counter it adds one point. How do I make it add a point when my laser kills (comes in contact with) an alien, and not when i click voidaddScore() ??
danpost danpost

2017/3/6

#
greenfoothighschooler wrote...
I've already added a scoreboard, and when I click on the voidaddScore() on the counter it adds one point. How do I make it add a point when my laser kills (comes in contact with) an alien, and not when i click voidaddScore() ??
The alien or the laser (whichever is performing the collision detection between the two objects) needs to obtain a reference to the counter object. Usually with something like this (if only one counter object is in the world):
((Counter)getWorld().getObjects(Counter.class).get(0)).addScore();
You need to login to post a reply.