mirror of
https://github.com/wassname/phaser.git
synced 2026-09-12 12:40:47 +08:00
TilemapLayers now render tiles correctly, with our without debugging overlay. Collision working well across single and index ranges.
This commit is contained in:
+17
-9
@@ -3,11 +3,11 @@ var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload:
|
||||
|
||||
function preload() {
|
||||
|
||||
// game.load.tilemap('map', 'assets/maps/mario1.json', null, Phaser.Tilemap.TILED_JSON);
|
||||
// game.load.tileset('marioTiles', 'assets/maps/mario1.png', 16, 16);
|
||||
game.load.tilemap('map', 'assets/maps/mario1.json', null, Phaser.Tilemap.TILED_JSON);
|
||||
game.load.tileset('tiles', 'assets/maps/mario1.png', 16, 16);
|
||||
|
||||
game.load.tilemap('map', 'assets/maps/newtest.json', null, Phaser.Tilemap.TILED_JSON);
|
||||
game.load.tileset('tiles', 'assets/maps/ground_1x1.png', 32, 32);
|
||||
// game.load.tilemap('map', 'assets/maps/newtest.json', null, Phaser.Tilemap.TILED_JSON);
|
||||
// game.load.tileset('tiles', 'assets/maps/ground_1x1.png', 32, 32);
|
||||
// game.load.image('phaser', 'assets/sprites/phaser-ship.png');
|
||||
// game.load.image('phaser', 'assets/sprites/mushroom2.png');
|
||||
// game.load.image('phaser', 'assets/sprites/wabbit.png');
|
||||
@@ -28,11 +28,19 @@ function create() {
|
||||
|
||||
map = game.add.tilemap('map');
|
||||
|
||||
// map.setCollisionByIndexRange(80, 97); // mario
|
||||
map.setCollisionByIndex(1);
|
||||
map.setCollisionByIndexRange(80, 97); // mario
|
||||
map.setCollisionByIndexRange(14, 18); // mario
|
||||
|
||||
|
||||
|
||||
// map.setCollisionByIndex(1); // newtest
|
||||
|
||||
|
||||
|
||||
// Phaser.TilemapLayer = function (game, x, y, renderWidth, renderHeight, tileset, tilemap, layer) {
|
||||
layer = game.add.tilemapLayer(0, 0, 800, 600, null, map, 0);
|
||||
// Need to get the x,y values working (adjust cameraOffset values)
|
||||
layer = game.add.tilemapLayer(0, 0, 800, 600, 'tiles', map, 0);
|
||||
layer.debug = true;
|
||||
|
||||
// layer2 = game.add.tilemapLayer(0, 0, 400, 600, null, map, 0);
|
||||
// layer.cameraOffset.x = 400;
|
||||
@@ -75,8 +83,8 @@ function create() {
|
||||
|
||||
function getIt() {
|
||||
|
||||
console.log('cam', game.camera.bounds);
|
||||
console.log('w', game.world.bounds);
|
||||
// console.log('cam', game.camera.bounds);
|
||||
// console.log('w', game.world.bounds);
|
||||
// console.log(layer.getTiles(sprite.body.x, sprite.body.y, sprite.body.width, sprite.body.height, true, true));
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user