In my game, everytime a bullet hits the asteroid, the score counter should increment by 1.
As shown in this code, I add the score counter into my ending screen world:
This is my score counter actor class:
I have a method in my Asteroid subclass that destroys the small asteroid every time a bullet hits it
This method is then implemented into my subclass asteroid (because I have different types of asteroids):
I have incremented the score, but how do I transfer the value of this scoreCount to the scoreCount in my ScoreCount class?
Right now my ScoreCount just shows 0 and is not incrementing.
Any help would be appreciated, thanks!
public class EndingWorld extends World
{
/**
* Constructor for objects of class EndingWorld.
*
*/
public EndingWorld()
{
// Create a new world with 700x500 cells with a cell size of 1x1 pixels.
super(700, 500, 1);
addObject(new EndingScreen(), 350, 250);
addObject(new ScoreCount(), 100, 400);
}
}public class ScoreCount extends AsteroidSubclass
{
public ScoreCount()
{
setImage(new GreenfootImage("Score = " + scoreCount, 18, Color.BLACK, Color.WHITE));
}
}public void bulletDestroySmallAsteroid()
{
if (intersectObject(Bullet.class))
{
destroy(Bullet.class);
getWorld().removeObject(this);
}
}public void act()
{
move(-4);
edgeEnd();
if(bulletDestroySmallAsteroid())
{
scoreCount = scoreCount + 1;
}
}
