You can now load in CSV Tilemaps again and they get created properly (fixes #391)

You can now create blank Tilemaps and then populate them with data later.
This commit is contained in:
photonstorm
2014-03-03 13:45:47 +00:00
parent 960e8cace6
commit 4a370c82cf
8 changed files with 170 additions and 31 deletions
+1 -1
View File
@@ -35,7 +35,7 @@ function create() {
layer.resizeWorld();
// Create our tile selector at the top of the screen
this.createTileSelector();
createTileSelector();
game.input.setMoveCallback(updateMarker, this);
+59
View File
@@ -0,0 +1,59 @@
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
// var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.tilemap('map', 'assets/tilemaps/csv/catastrophi_level2.csv', null, Phaser.Tilemap.CSV);
game.load.image('tiles', 'assets/tilemaps/tiles/catastrophi_tiles_16.png');
}
var map;
var layer;
var cursors;
function create() {
// Because we're loading CSV map data we have to specify the tile size here or we can't render it
map = game.add.tilemap('map', 16, 16);
// Now add in the tileset
map.addTilesetImage('tiles');
// Create our layer
layer = map.createLayer(0);
// Resize the world
layer.resizeWorld();
// Allow cursors to scroll around the map
cursors = game.input.keyboard.createCursorKeys();
}
function update() {
if (cursors.left.isDown)
{
game.camera.x -= 4;
}
else if (cursors.right.isDown)
{
game.camera.x += 4;
}
if (cursors.up.isDown)
{
game.camera.y -= 4;
}
else if (cursors.down.isDown)
{
game.camera.y += 4;
}
}
function render() {
}