Skip to main content
Game Builder - Additional Features

This article will dive deeper into some features in Game Builder - game properties, sounds, tilemaps and general functions.

Livnat Hershkovitz avatar
Written by Livnat Hershkovitz
Updated over 9 months ago

The following topics will be reviewed:


Game Tab

The game tab is where we define the attributes for our game.

For example: having gravity in the game, the width and height of the world and so on.

These settings can be changed prior to running the game and cannot be changed in the code.

Settings

Name

Description

Background image

The background image of the game can be changed to either an existing background or an uploaded one.

World width

Sets the world’s width.

The visible part of the world is 600 by 400.

World height

Sets the world’s height.

The visible part of the world is 600 by 400.

Camera target

Defines which sprite to follow. When the game runs, the camera will move following the sprite.

When the world size is 600 by 400, setting this option is meaningless because the entire world can be seen.

Gravity

Defines the level of gravity in the game.

Zero means that there is no gravity and the sprites do not fall down.

The gravity also affects how high the sprite jumps or how fast it falls.

Physics

Defines the physics system of the game.

Use Arcade when you need simple physics like in a platformer game.

P2 physics allows complex physics in the game. P2 physics can be used for games such as moon lander.

Note: some functions are available only for arcade physics and some only for P2 physics.

Tip

When the world’s width and height are different from the default values (600 pixels and 400 pixels respectively), the camera target should be set as well. Otherwise, when the sprite moves out of the visible part of the world, it will be out of camera’s sight.


Properties

The table below lists all properties that can be used in the code.

Name

Description

Returns the time elapsed in milliseconds.


game.time.now

Shows the time elapsed in milliseconds (thousandths of a second).

Example

game.time.now

Functions

The table below lists all functions that can be used in the code.

The functions can be used with both physics (arcade and P2).

Function Name

Description

Resets the game.

Pauses the game.

Resumes the game.


game.reset()

Resets the game to its original configuration.

Example

When the following code will be reached, the game will restart to its original configuration.

game.reset()


game.pause()

Pauses the game.

Example

When the following code will be reached, the game will pause, sprites will not be moved, timer widgets will stop counting.

game.pause()


game.unpause()

Resumes the game.

Example

When the following code will be reached, the game will resume, timer widgets will continue counting from the place they were paused.

game.unpause()


Sounds Tab

Sounds are objects in the game. Sound objects can be played by calling the "play" function of the sound object. There are various sounds available. The sound can be played before adding it to the game by clicking on the play button.

Functions

Function Name

Description

Plays the sound


play()

Plays the sound.

Examples

Plays a sound named mySound.

mySound.play()


Tilemaps

Tilemap consists of tiles that can be added to the game.

When using arcade physics, the tiles are used as the ground of the game, meaning sprites can move and jump on them. If gravity is applied to the sprite, then when the game runs, the sprite will fall and land on a tile.

When using P2 physics, the function onCollideWithTilemap can be used to define what to do in case the sprite collides with any of the tiles in the game.

Actions

Action Name

Description

Add

Add tiles

Erase

Erase tiles

There are two icons located on the top right corner of the game screen.

To add tiles, click on the paint brush icon. The available patterns of the tiles are opened on the right-side of the screen. Choose one pattern and click on the screen to add the tiles. Once done, click on the arrow icon (otherwise, each click on the screen will add another tile).

To delete tiles, click on the eraser icon. Go over the tiles that needs to be erased. Once done, click on the arrow icon (otherwise, each click on the screen will erase another tile).


General Functions

These functions can be used in the sprites’ and in widgets’ codes.

Functions

Function Name

Description

Returns a number between the minimum number and the maximum number.


random min, max

Returns a random number in between the range of the minimum and maximum numbers provided. Each call to this function will return a different number.

Arguments

Name

Type

Description

min

number

The minimum number that can be returned.

max

number

The maximum number that can be returned.

Returns

Number - a random number between min and max.

Example

x = random 1, 3  # x is assigned a random number between 1 and 3 


Relevant Articles:

Did this answer your question?