我正在尝试移相器,我创建了一个带有 Tiled 的 Tiles Map,我在移相器上“导入”了它。

Everythign 工作正常,唯一的问题是我没有找到如何将 TilesMap(比 Canvas 大 60 像素)适合 Canvas 。我看了所有的例子,但我什么也没找到。

不是这个功能的工作吗? layer.resizeWorld()

var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
var map;
var tileset;
var layer;
var player;
var cursors;



function preload() {
    game.load.tilemap('map', 'assets/maps/map.json', null, Phaser.Tilemap.TILED_JSON);
    game.load.image('tiles', 'assets/tiles/tilesSheet.png');
}

function loadUpdate(){
}

function create() {
    map = game.add.tilemap('map');
    map.addTilesetImage('tilesSheet','tiles');
    layerGround = map.createLayer("Ground");
    layerObstacle = map.createLayer("Obstacle");
    //  Un-comment this on to see the collision tiles
    // layer.debug = true;
    layerGround.resizeWorld();
}

function update() {
}

function render() {
}

最佳答案

layer.resizeWorld() 将调整游戏世界的大小以匹配您的 tilemap 的大小。它不会对 Canvas 对象做任何事情。无论您在 Game 构造函数中为您的游戏指定的大小是 Canvas 将被创建和显示的大小。所以在你上面的例子中,它将制作一个 800x600 大小的 Canvas 。

关于phaser-framework - 在移相器上制作适合 TilesMap 的 Canvas ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22310251/

10-12 12:43
查看更多