I have made a game in flash CS6 using AS3 and Air 3.2 for Android, now this game you go to different menus, when you die, it will go back to main menu and show your score, now when you select a new character and play through again, the monsters speed are doubled!?!?
Any idea why? I can give you a piece of my code but I'm really not sure on what part is the problem? would it be a event listener that wasn't deleted?
Here is the function that is called to started the level off
public function startLevel1( navigationEvent:NavigationEvent ):void
{
//classSelect = null;
removeChild( classSelect );
levelManager = new LevelManager( heroGra, hero);
addChild( levelManager );
levelManaOn = true;
gameTimer = new Timer( 30 );
//On every 30ms we call apon moveEvent function
gameTimer.addEventListener( TimerEvent.TIMER, tick );
gameTimer.start();
}
Here is the tick event that is deleted that calls the updated function for the monsters
public function tick( timerEvent:TimerEvent ):void
{
if(levelManaOn == true)
{
levelManager.update();
if(hero.hp <= 0)
{
trace("DEAD");
onScoreState();
levelManaOn = false;
removeEventListener( TimerEvent.TIMER, tick );
}
}
}
From tick event, it will call this function
public function onScoreState( ):void
{
scoreState = new ScoreState();
scoreState.waveCompletedScore.text = levelManager.level.score.toString();
//
scoreState.addEventListener( NavigationEvent.ENDGAME, backMainMenu );
addChild( scoreState );
removeChild( levelManager );
}
this removes levelManager, but still the monsters move at double the speed, and every time you restart from the beginning after dieing, the speed is doubled again, and again, any idea why?
Thank you reading and for the help
Canvas