Jump to content

Phaser.Tileset - actual and expected number of tile rows and columns differ


douglas
 Share

Recommended Posts

Hi,

What does it mean ? please

here is my project 

var game;
var map;
var layer;
var player;
var cursors;

game = new Phaser.Game(640, 480, Phaser.CANVAS, 'Zelda Mysteries of PhaserIO', { preload: preload, create: create, update: update, render: render });

function preload() {

    game.load.tilemap('hyrule', 'assets/tiles/hyrule.json', null, Phaser.Tilemap.TILED_JSON);
    game.load.image('light_world', 'assets/tiles/light_world.tiles.png');
    game.load.spritesheet('link', 'assets/sprites/walking.tunic.png', 24, 32, 55);
}

function create() {
//World


    map = game.add.tilemap('hyrule');
    map.addTilesetImage('light_world.tiles', 'light_world');

    layer = map.createLayer('Calque de Tile 1');
    layer.resizeWorld();

    map.setCollision(20, true, layer);
    game.physics.startSystem(Phaser.Physics.ARCADE);

    game.world.setBounds(0, 0, 1280, 960);
//Player
    player = game.add.sprite(50, 150, 'link');
    player.scale.set(2);
    player.smoothed = false;

    player.animations.add('right', [0, 1, 2, 3, 4, 5, 6, 7], 20, false);
    player.animations.add('up', [12, 13, 14, 15, 16, 17, 18], 8, false);
    player.animations.add('left', [33, 34, 35, 36, 37, 38, 39, 40], 8, false);
    player.animations.add('down', [44, 45, 46, 47, 48, 49, 50, 51], 8, false);

    game.physics.enable(player);
    game.camera.follow(player);

    cursors = game.input.keyboard.createCursorKeys();

}

function update() {
    game.physics.arcade.collide(player, layer);
    player.body.collideWorldBounds = true;

    player.body.velocity.x = 0;
    player.body.velocity.y = 0;

    var speed = 200;

    if (cursors.right.isDown)
    {
        game.camera.x += 4;
        player.body.velocity.x = +speed;
        player.animations.play('right');
    }

    else if (cursors.up.isDown)
    {
        game.camera.y -= 4;
        player.body.velocity.y = -speed;
        player.animations.play('up');
    }

    else if (cursors.left.isDown)
    {
        game.camera.x -= 4;
        player.body.velocity.x = -speed;
        player.animations.play('left');
    }

    else if (cursors.down.isDown)
    {
        game.camera.y += 4;
        player.body.velocity.y = +speed;
        player.animations.play('down');
    } else {

        player.animations.stop();
    }

}

function render() {

    game.debug.spriteInfo(player, 20, 32);

}

 

hyrule.json

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...