Scenes > View


Read our article on Backgrounds and Camera for an explanation of some of these blocks.


Screen Bounds

Camera Position

x of camera

Returns the camera's horizontal (X) or vertical (Y) position.

getScreenX()
getScreenY()
getScreenXCenter()
getScreenYCenter()

Screen Size

screen width

Returns the game's screen width/height.

getScreenWidth()
getScreenHeight()

Camera

Move Camera

move camera center to x number y number

Moves the camera to the given point.

engine.moveCamera([NUMBER], [NUMBER]);

Move Camera to Actor

move camera center to actor

Moves the camera to the given actor's location.

engine.cameraFollow([ACTOR]);

Effects

Shake Screen

shake screen for number sec with intensity number %

Shakes the screen for the specified time. Good for conveying explosions or earthquakes. Intensity specifies how "violent" the shaking is.

startShakingScreen([NUMBER] / 100, [NUMBER]);

Stop Shaking Screen

stop shaking screen

Immediately stop shaking the screen.

stopShakingScreen();

Color Background

Set Background to Color

set color background to solid color color

Changes the background color to a solid color (if you don't have an image background covering it up).

setColorBackground([COLOR]);

Set Background to Gradient

set color background to vertical gradient with color and color

Changes the background color to a vertical gradient (if you don't have an image background covering it up).

setColorBackground([COLOR], [COLOR]);

Layer Properties

Layer Exists

layer with id object exists

Returns true if a layer with the given name or ID exists.

(engine.getLayerById([INT], false) != null)
(engine.getLayerByName([TEXT], false) != null)

Set Autoscroll Speed (for layer)

set autoscroll speed for background with id object to x number y number

Changes the speed that the specified background layer (automatically) scrolls at. The layer must be designated as scrolling to begin with for this to work.

setScrollSpeedForBackground(engine.getLayerById([INT]), [NUMBER], [NUMBER]);
setScrollSpeedForBackground(engine.getLayerByName([TEXT]), [NUMBER], [NUMBER]);

Set Scroll Factor for (for layer)

set scroll factor for layer with id object to x number y number

Change the speed at which any layer scrolls, as a percentage of the baseline. In other words, 100% is the original value, 200% is twice as much and 50% is half as much.

setScrollFactorForLayer(engine.getLayerById([INT]), [NUMBER], [NUMBER]);
setScrollFactorForLayer(engine.getLayerByName([TEXT]), [NUMBER], [NUMBER]);

Show / Hide Layer

hide layer with id object

Shows/Hides the given layer.

hideTileLayer(engine.getLayerById([INT]));
hideTileLayer(engine.getLayerByName([TEXT]));

showTileLayer(engine.getLayerById([INT]));
showTileLayer(engine.getLayerByName([TEXT]));

Fade Layer

fade layer with id object to number % over number secs

Fades the given layer to the specified opacity value (0 - 100%) over time.

fadeTileLayerTo(engine.getLayerById([INT]), [NUMBER]/100, [NUMBER]);
fadeTileLayerTo(engine.getLayerByName([TEXT]), [NUMBER]/100, [NUMBER]);

Opacity of Layer

opacity of layer with id object

Returns the opacity of layer (0% - 100%) with the given name or ID.

getTileLayerOpacity(engine.getLayerById([INT]))
getTileLayerOpacity(engine.getLayerByName([TEXT]))

Set Blend Mode (for layer)

set blend mode for layer with id object to dropdown

Set the Blend Mode for the specified layer.

setBlendModeForLayer(engine.getLayerById([INT]),[BLEND MODE]);
setBlendModeForLayer(engine.getLayerByName([TEXT]),[BLEND MODE]);

Change Background Image (for layer)

change image for background layer with id object to image

Change the image displayed in the specified background layer.

changeBackgroundImage(engine.getLayerById([INT]), [IMAGE]);
changeBackgroundImage(engine.getLayerByName([TEXT]), [IMAGE]);

Add / Remove Layers

Create Tile Layer

create tile layer with name text at z index int

Add a new layer for tiles and actors. Provide the name of the new layer and the drawing order (z-order). 0 is the back, higher numbers display on top.

addTileLayer([TEXT], [INT]);

Create a Background Layer

create background layer with name text using background text at z index int

Add a new background layer. Provide the name, the name of the Background resource and the drawing order (z-order). 0 is the back, higher numbers display on top.

addBackground([TEXT], [TEXT], [INT]);

Create a Background Layer (from image)

create tiled background layer with name text using image at z index int

Add a new background layer using an image. Provide the image, name and drawing order (z-order). 0 is the back, higher numbers display on top.

addBackgroundFromImage([IMAGE], true, [TEXT], [INT]); //tiled background
addBackgroundFromImage([IMAGE], false, [TEXT], [INT]); //regular background

Remove Layer

remove layer with id object

Remove the specified layer. The behavior of objects that still exist on this layer when it is removed is unspecified.

engine.removeLayer(engine.getLayerById([INT]));
engine.removeLayer(engine.getLayerByName([TEXT]));

Layer Order

Set Drawing Order for Layer

set z index of layer with id object to int

Set the drawing order of the specified layer. 0 is the back, higher numbers display on top.

engine.moveLayerToOrder(engine.getLayerById([INT]), [INT]);
engine.moveLayerToOrder(engine.getLayerByName([TEXT]), [INT]);

Get Drawing Order for Layer

z index of layer with id object

Get the drawing order of the specified layer. 0 is the back, higher numbers display on top.

engine.getOrderOfLayer(engine.getLayerById([INT]))
engine.getOrderOfLayer(engine.getLayerByName([TEXT]))

Number of Layers

number of layers

Returns the number of layers in the current scene.

engine.getNumberOfLayers()

Offscreen Bounds

Set Offscreen Bounds

set offscreen bounds to top number left number bot number right number

Used to set how far actors have to be off-screen to be considered off screen.

setOffscreenTolerance([NUMBER], [NUMBER], [NUMBER], [NUMBER]);