在Phaser JS中设置世界范围

时间:2016-02-27 15:57:18

标签: javascript phaser-framework

我试图将世界高度设定为900000,但Phaser似乎停在13860:

game.world.setBounds(0, 0, 1400, 900000);

PhaserJS中是否存在某种限制?

3 个答案:

答案 0 :(得分:3)

在我开始编写游戏时偶然发现了这个问题。使用比 Canvas 宽度和高度更宽和更高的 TileMap。我正在使用 Phaser 3,解决方案很简单!

this.physics.world.setBounds( 0, 0, full-width, full-height );

我也在寻找它,我在 Phaser.Physics.Arcade 中发现了 bounds 对象和 setBounds 函数(呃,它会不会在物理学中!)

无论如何,希望它有所帮助。

答案 1 :(得分:2)

我在documentationsource中找不到任何世界限制。

此外,状态(TypeScript)中的以下代码在直接请求时以及相机调试信息中正确返回设置的世界宽度和高度。

module TestingProject {
    export class WorldBounds extends Phaser.State {
        init() {
            this.game.world.setBounds(0, 0, 1400, 900000);
        }

        create() {
            var fontStyle = { fill: '#fff' };

            // Returns 1400
            var worldWidthText = this.game.add.text(50, 150,
                "World width: " + this.game.world.bounds.width, fontStyle);
            // Returns 900000
            var worldHeightText = this.game.add.text(50, 200,
                "World height: " + this.game.world.bounds.height, fontStyle);
        }

        render() {
            // Returns bounds of x,y = 0,0 and w,h = 1400,900000
            this.game.debug.cameraInfo(this.camera, 50, 50);
        }
    }
}

答案 2 :(得分:0)

老实说,我找不到任何有关限制的文件,似乎没有。

相关问题