javascript - Setting world bounds in Phaser JS - Stack Overflow

admin2025-04-18  0

I am trying to set a world height of 900000, but Phaser seems to stop at 13860:

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

Is there some sort of limits to bounds in PhaserJS?

I am trying to set a world height of 900000, but Phaser seems to stop at 13860:

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

Is there some sort of limits to bounds in PhaserJS?

Share Improve this question asked Feb 27, 2016 at 15:57 jhtongjhtong 1,5894 gold badges23 silver badges34 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 3

Stumbled upon this issue as I started writing my game. Working with TileMaps that are way wider and higher than the Canvas width and height. I'm working with Phaser 3, and the solution for this is simple!

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

I was searching for it as well, and I discovered the bounds object and the setBounds function in Phaser.Physics.Arcade ( duh, of could it would be in physics! )

Anyway, hope it helps.

I've been unable to find any mention of world limits in the documentation or source.

Additionally, the following code in a state (TypeScript) correctly returns the set world width and height when requested directly, as well as in the camera debug info.

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);
        }
    }
}

Honestly, I could not find any documentation about the bound limits, it seems that there isnt one.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1744970387a277452.html

最新回复(0)