如何使用Phaser 2设计等轴测场景

时间:2018-09-28 08:52:32

标签: javascript phaser-framework isometric

我需要使用Phaser框架制作一个大的(4032x1440px)等轴测图。我尝试使用等距插件,但不适用于等距贴图。我将图层作为单独的精灵加载,但水平却非常沉重且缓慢,当我与物理进行叠加时,街机碰撞与地图不匹配。

我还尝试使用P2物理将场景制作为一张大图像,并且它可以工作,但是如果我不使用图块,我不知道如何检查位置。

gameObject.physics.startSystem(Phaser.Physics.P2JS);

this.scenery = new Phaser.Group(gameObject, gameObject.world, null, false, true, Phaser.Physics.P2);
this.levelData = gameObject.cache.getPhysicsData('location1_physics');
this.scenery = new Phaser.Group(gameObject, gameObject.world, null, false, true, Phaser.Physics.P2);
this.levelData = gameObject.cache.getPhysicsData('location1_physics');
for (var j = 0; j < this.levelData.layers[1].objects.length; j++) {
    this.scenery.addAt(gameObject.add.sprite(this.levelData.layers[1].objects[j].x, this.levelData.layers[1].objects[j].y), j);
    gameObject.physics.p2.enable(this.scenery.children[j], true);
    this.scenery.children[j].body.clearShapes();
    this.scenery.children[j].body.fixedRotation = true;
    this.scenery.children[j].body.kinematic = true;
    thepolygon = this.levelData.layers[1].objects[j].polygon;
    //thepolygon.immovable = true;
    thepolygon.visible = false;
    polygonarray = [];
    for (var k = 0; k < thepolygon.length; k++) {
        polygonarray[k] = [thepolygon[k].x, thepolygon[k].y];
    }
    this.scenery.children[j].body.addPolygon({}, polygonarray);
}
console.log('physics is loaded');

mapImage = gameObject.add.sprite(0, 0, 'location1_sprite');

有什么方法可以用Phaser制作等距图(工作示例或源代码)?

0 个答案:

没有答案