I’ve had this problem for a while now and I really don’t know how to fix it. I have a class called PlayerWeapon that gets added to the game every time the player hits the Play button. This is the function that I have right in the PlayerWeapon class:
private function init(e:Event):void
{
currentWeapon = "Bullet";
switch(currentWeapon)
{
case "Bullet":
timeToShoot = 40;
shootTimeMax = 40;
shootSpeed = 5;
break;
}
}
Eventually other weapons will be available, but for now the only thing that matters is shootTimeMax (reload speed) and shootSpeed. Now these variables work fine, and for testing purposes I’ve added an event listener to the stage that shortens the reload speed every time the player clicks. Everything works great, until the player decides the quit the game and retry. Even though the PlayerWeapon class is re-added, the variables do not reset.
By the way, all these variables are public static, which I assume has to do with the issue. However, I need them to be public so I can access them through the other classes.