Scene > View


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


Screen Bounds

Camera Position

screen-xy

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

getScreenX()
getScreenY()

Screen Size

screen-wh

Returns the game's screen width/height.

getScreenWidth()
getScreenHeight()

Camera

Move Camera

camera-move

Moves the camera to the given point.

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

Move Camera to Actor

camera-follow

Moves the camera to the given actor's location.

engine.cameraFollow([ACTOR]);

Effects

Shake Screen

shake-start

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

shake-stop

Immediately stop shaking the screen.

stopShakingScreen();

Toggle Full-Screen Mode

toggle-fullscreen

Enables/Disables full-screen mode for Flash & Desktop targets.

toggleFullScreen();

Color Background

Set Background to Color

set-color-bg

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-grad-bg

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

setColorBackground([COLOR], [COLOR]);

Layer Properties

Set Autoscroll Speed (for layer)

set-bg-speed

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(0, [TEXT], [NUMBER], [NUMBER]); //specify a layer ID
setScrollSpeedForBackground(1, [TEXT], [NUMBER], [NUMBER]); //specify a layer name

Set Scroll Factor for (for layer)

set-layer-scrollfactor

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(0, [TEXT], [NUMBER], [NUMBER]); //specify a layer ID
setScrollFactorForLayer(1, [TEXT], [NUMBER], [NUMBER]); //specify a layer name

Show / Hide Layer

showhide-layer2

Shows/Hides the given layer.

showTileLayer(0, [TEXT]); //specify a layer ID
showTileLayer(1, [TEXT]); //specify a layer name

hideTileLayer(0, [TEXT]); //specify a layer ID
hideTileLayer(1, [TEXT]); //specify a layer name

Fade Layer

fadeTo-layer2

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

fadeTileLayerTo(0, [TEXT], [NUMBER]/100, [NUMBER]); //specify a layer ID
fadeTileLayerTo(1, [TEXT], [NUMBER]/100, [NUMBER]); //specify a layer name

Set Blend Mode (for layer)

set-blend-layer2

Set the Blend Mode for the specified layer.

setBlendModeForLayer(0, [TEXT], [BLEND MODE]); //specify a layer ID
setBlendModeForLayer(1, [TEXT], [BLEND MODE]); //specify a layer name

Change Background Image (for layer)

set-bg-image

Change the image displayed in the specified background layer.

changeBackgroundImage(0, [TEXT], [IMAGE]); //specify a layer ID
changeBackgroundImage(1, [TEXT], [IMAGE]); //specify a layer name

Add/Remove Layers

Create a Background Layer

create-bglayer-from-bg

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], [NUMBER]);

Create a Background Layer (from image)

create-bglayer-from-image

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], [NUMBER]); //tiled background
addBackgroundFromImage([IMAGE], false, [TEXT], [NUMBER]); //regular background

Remove Background Layer

remove-bglayer

Remove the specified background layer.

removeBackground(0, [TEXT]); //specify a layer ID
removeBackground(1, [TEXT]); //specify a layer name

Layer Order

Set Drawing Order for Layer

set-layer-order

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

engine.moveLayerToOrder(0, [TEXT], [NUMBER]); //specify a layer ID
engine.moveLayerToOrder(1, [TEXT], [NUMBER]); //specify a layer name

Get Drawing Order for Layer

get-layer-order

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

engine.getOrderOfLayer(0, [TEXT]) //specify a layer ID
engine.getOrderOfLayer(1, [TEXT]) //specify a layer name

Number of Layers

numlayers

Returns the number of layers in the current scene.

engine.getNumberOfLayers()

Offscreen Bounds

Set Offscreen Bounds

offscreen

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

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