mirror of
https://github.com/wassname/phaser.git
synced 2026-07-21 12:40:56 +08:00
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:
@@ -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);
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user