Worlds (Code Template)

Return to Coding -&gt;

TEMPLATE
package Worlds { import Cameras.C_Play; import Entities.Player; import net.flashpunk.World;

public class W_Dark_One extends World {

// This will initiated a camera object that can be manipulated anywhere in the world internal var cur_camera:C_Play; public function W_Dark_One {

// This is an example of creating the camera and adding it. The Parameters are in pixels cur_camera = new C_Play(0, 1600, 0, 1600, 300, 250, 250); add(cur_camera);

// This will create the grid lines as a 50 by 50 squares area starting at (0,0) squares Grid(0, 0, 50); }

// typing [override update] and hitting enter will bring up this function override public function update:void {

// Add in this line so that Setup gets run everytime there is a scene transition if (transition) Setup; super.update; }

// Typing up this whole function will let the world work properly and even make the player (he will fall, though) private function Setup:void {

// THIS LINE IS VERY IMPORTANT transition = false; if (scene == 0) {            add(new Player(0, 50)); }    } }

}