Class: Game

Carrot.Game(widthopt, heightopt, containeropt, sceneopt, transparentopt)

Carrot.Game

Constructor

new Game(widthopt, heightopt, containeropt, sceneopt, transparentopt)

The core game object. Starts the game.
Parameters:
Name Type Attributes Default Description
width integer <optional>
800 The width of the container.
height integer <optional>
600 The height of the container.
container string <optional>
null The parent div of the container.
scene object <optional>
null Custom scene the game shall use.
transparent boolean <optional>
false Defines if the container shall be transparent.
Source:

Methods

setBounds(widthopt, heightopt)

Sets the size of the game container.
Parameters:
Name Type Attributes Default Description
width integer <optional>
800 The right bound of the game container.
height integer <optional>
600 The bottom bound of the game container.
Source:

setBoundsToCamera()

Sets the size of the game container to the size of the camera.
Source:

setBoundsToWorld()

Sets the size of the game container to the size of the game world.
Source:

setCursor(key, xopt, yopt)

Sets the cursor image shown when the mouse is hovering the game container.
Parameters:
Name Type Attributes Default Description
key key The key (name) of the image to be used. If the image is not a previously loaded game asset, it will use the browser's set of default cursors.
x integer <optional>
0 The x coordinate of the cursor's hotspot.
y integer <optional>
0 The y coordinate of the cursor's hotspot.
Source: