override public void create() { FlxG.Framerate = 50; //FlxG.flashFramerate = 50; // Creates a new tilemap with no arguments collisionMap = new FlxTilemap(); /* * FlxTilemaps are created using strings of comma seperated values (csv) * This string ends up looking something like this: * * 0,0,0,0,0,0,0,0,0,0, * 0,0,0,0,0,0,0,0,0,0, * 0,0,0,0,0,0,1,1,1,0, * 0,0,1,1,1,0,0,0,0,0, * ... * * Each '0' stands for an empty tile, and each '1' stands for * a solid tile * * When using the auto map generation, the '1's are converted into the corresponding frame * in the tileset. */ // Initializes the map using the generated string, the tile images, and the tile size collisionMap.loadMapFile(default_auto, auto_tiles, (int)TILE_WIDTH, (int)TILE_HEIGHT, FlxTilemap.AUTO); add(collisionMap); highlightBox = new FlxObject(0, 0, TILE_WIDTH, TILE_HEIGHT); setupPlayer(); // When switching between modes here, the map is reloaded with it's own data, so the positions of tiles are kept the same // Notice that different tilesets are used when the auto mode is switched autoAltBtn = new FlxButton(4, FlxG.height - 24, "AUTO", altButtonFunc); add(autoAltBtn); resetBtn = new FlxButton(8 + autoAltBtn.Width, FlxG.height - 24, "Reset", resetButtonFunc); add(resetBtn); quitBtn = new FlxButton(FlxG.width - resetBtn.Width - 4, FlxG.height - 24, "Quit", onQuit); add(quitBtn); helperTxt = new FlxText(5, 5, 150, "Click to place tiles. Shift-Click to remove tiles\nArrow keys to move"); add(helperTxt); // Show mouse pointer FlxG.mouse.show(); }
private void resetButtonFunc() { switch (collisionMap.auto) { case FlxTilemap.AUTO: collisionMap.loadMapFile(default_auto, auto_tiles, TILE_WIDTH, TILE_HEIGHT, FlxTilemap.AUTO); player.X = 64; player.Y = 220; break; case FlxTilemap.ALT: collisionMap.loadMapFile(default_alt, alt_tiles, TILE_WIDTH, TILE_HEIGHT, FlxTilemap.ALT); player.X = 64; player.Y = 128; break; case FlxTilemap.OFF: collisionMap.loadMapFile(default_empty, empty_tiles, TILE_WIDTH, TILE_HEIGHT, FlxTilemap.OFF); player.X = 64; player.Y = 64; break; } }