Skip to content

Instantly share code, notes, and snippets.

@zachwlewis
Forked from sjakaus/gist:579517
Created September 14, 2010 18:55
Show Gist options
  • Save zachwlewis/579556 to your computer and use it in GitHub Desktop.
Save zachwlewis/579556 to your computer and use it in GitHub Desktop.
//Master.as
package
{
public class Master
{
public static var levelData:Vector.<DungeonWorld>;
public static var currentLevel:uint = 0;
}
}
//DungeonWorld.as
package
{
import net.flashpunk.*;
import Master;
public class DungeonWorld extends World
{
public function DungeonWorld()
{
// If our global variables aren't instantiated yet, let's do that here.
if(Master.levelData == null)
{
Master.levelData = new Vector.<DungeonWorld>;
}
else
{
trace(Master.currentLevel);
}
}
override public function begin():void
{
add(new Level());
add(new Player(FP.screen.width/2,FP.screen.height/2));
}
override public function end():void
{
Master.levelData.push(this);
Master.currentLevel++;
super.end();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment