Prerequisite: use a current version of PushButton Engine.
This will be a short tutorial. It will show you how to intialize your PushButton Engine scene properly via ActionScript.
Let’s get started! Somewhere in your main class, paste in this code:
// Startup the engine: PBE.startup(this); //Create your scene view: var sceneView:com.pblabs.rendering2D.ui.SceneView = new com.pblabs.rendering2D.ui.SceneView(); //And now initialize the scene: PBE.initializeScene( sceneView, "Scene", null, Box2DManagerComponent ); //Now you're ready to load a level file like so: LevelManager.instance.load("../assets/levelDescriptions.xml", 1); //Or create your entites directly in code: var myEntity:IEntity = PBE.allocateEntity(); myEntity.initialize("MyEntity"); //...go on with adding components to your entity as you like :)
A quick remark on the initializeScene: if you don’t want or need the Box2DManagerComponent, you can use the BasicSpatialManager2D:
PBE.initializeScene( sceneView, "Scene", null, BasicSpatialManager2D );
That was it! Easy eh?
In case this is not clear: if you load a XML level, you want to use
for all classes that are in your XML files. Otherwise they cannot be deserialized.
You also wanna make sure, that you loaded all your resources properly!