new World(game)
"This world is but a canvas to our imagination." - Henry David Thoreau
A game has only one world. The world is an abstract place in which all game objects live. It is not bound by stage limits and can be any size. You look into the world via cameras. All game objects live within the world at world-based coordinates. By default a world is created the same size as your Stage.
Parameters:
Name | Type | Description |
---|---|---|
game |
Phaser.Game | Reference to the current game instance. |
- Source:
Members
-
bounds
-
The World has no fixed size, but it does have a bounds outside of which objects are no longer considered as being "in world" and you should use this to clean-up the display list and purge dead objects. By default we set the Bounds to be from 0,0 to Game.width,Game.height. I.e. it will match the size given to the game constructor with 0,0 representing the top-left of the display. However 0,0 is actually the center of the world, and if you rotate or scale the world all of that will happen from 0,0. So if you want to make a game in which the world itself will rotate you should adjust the bounds so that 0,0 is the center point, i.e. set them to -1000,-1000,2000,2000 for a 2000x2000 sized world centered around 0,0.
- Source:
Properties:
Name Type Description bounds
Phaser.Rectangle Bound of this world that objects can not escape from.
-
camera
-
- Source:
Properties:
Name Type Description camera
Phaser.Camera Camera instance.
-
<readonly> centerX
-
- Source:
Properties:
Name Type Description centerX
number Gets the X position corresponding to the center point of the world.
-
<readonly> centerY
-
- Source:
Properties:
Name Type Description centerY
number Gets the Y position corresponding to the center point of the world.
-
currentRenderOrderID
-
- Source:
Properties:
Name Type Description currentRenderOrderID
number Reset each frame, keeps a count of the total number of objects updated.
-
height
-
- Source:
Properties:
Name Type Description height
number Gets or sets the current height of the game world.
-
<readonly> randomX
-
- Source:
Properties:
Name Type Description randomX
number Gets a random integer which is lesser than or equal to the current width of the game world.
-
<readonly> randomY
-
- Source:
Properties:
Name Type Description randomY
number Gets a random integer which is lesser than or equal to the current height of the game world.
-
scale
-
- Source:
Properties:
Name Type Description scale
Phaser.Point Replaces the PIXI.Point with a slightly more flexible one.
-
visible
-
- Source:
Properties:
Name Type Description visible
boolean Gets or sets the visible state of the World.
-
width
-
- Source:
Properties:
Name Type Description width
number Gets or sets the current width of the game world.
Methods
-
<protected> boot()
-
Initialises the game world.
- Source:
-
destroy()
-
Destroyer of worlds.
- Source:
-
postUpdate()
-
This is called automatically every frame, and is where main logic happens.
- Source:
-
setBounds(x, y, width, height)
-
Updates the size of this world. Note that this doesn't modify the world x/y coordinates, just the width and height. If you need to adjust the bounds of the world
Parameters:
Name Type Description x
number Top left most corner of the world.
y
number Top left most corner of the world.
width
number New width of the world.
height
number New height of the world.
- Source:
-
update()
-
This is called automatically every frame, and is where main logic happens.
- Source: