I have made a score counter for my game, but whenever I shoot an enemy the score resets instead of adding.
Here is my code in MyWorld:
and this is my code in the projectile:whenever I shoot the projectile and hit something, the code displays the amount of score it's supposed to, but when I shoot another projectile the score goes back down to 0, how do i fix this?
public static int score=0;
public void act()
{
showText("Score: " + score,350,350);
}
MyWorld score;
int scoreUfo=0;
int scoreUfoRot=0;
int scoreUfoTel=0;
public void act()
{
if(getY()>1)
{
this.move();
punkteAdd();
}
else
{
this.getWorld().removeObject(this);
}
}
public void scoreAdd()
{
Actor Ufo;
Ufo = this.getOneIntersectingObject(Ufo.class);
if(Ufo != null)
{
scoreUfo=scoreUfo+10;
}
Actor UfoRot;
UfoRot = this.getOneIntersectingObject(UfoRotating.class);
if(UfoRot != null)
{
scoreUfoRot=scoreUfoRot+20;
}
Actor UfoTel;
UfoTel = this.getOneIntersectingObject(UfoTeleport.class);
if(UfoTel != null)
{
scoreUfoTel=scoreUfoTel+50;
} score.score=scoreUfo+scoreUfoRot+scoreUfoTel;
}

