Code is in Java. My code only triggers when the main character has killed all the monsters in the map he is in and has exited the current map to go to a different map.
The code below is written in Screen1 class which is the second map in the game because I am counting from zero. So Screen0 class will be the first map in the game.
if(numOfMonsters == 0 && link.getRectangle().intersects(rectangle))
numOfMonsters = 9;
for(int i = 0; i < numOfMonsters;i++)
Pig pig = new Pig(getWidth() - (getWidth() * widthData[i]),getHeight() - (getHeight() * heightData[i]));
For some reason, there is a delay that slows the game down for one whole second when I create the monsters back at the moment the character has exited the screen. The way I handle the main character exiting the screen is when he has collided with the rectangle in the map.
The reason I wrote the monster creation code this way is because for every monster that dies by the main character, that monster gets removed from the monsterList so I need to re-add them back when the main character has killed all the monster on the current map.
This monster creation code is exactly the same as the one I wrote in the Screen1 class constructor when the main character loads the map for the first time.
Edited by warnexus, 16 January 2014 - 06:59 PM.