System actions

This section describes all the actions in the built-in System object in Construct 2. They are listed in the order they appear in the Add Action dialog.

Display

Set canvas size
Set the size of the canvas area in the page, if appearing inline to the page (i.e. a fullscreen mode is not used). If a fullscreen mode is in use, this effectively changes the size of the Window size project property, which adjusts the size of the viewport.

Set fullscreen scaling
Set the Fullscreen scaling project property. This allows the quality setting to be adjusted at runtime.

Set pixel rounding
Set the Pixel rounding project property at runtime.

Snapshot canvas
Take a screenshot of the current display. This triggers On canvas snapshot when the snapshot is ready, and the resulting image can be accessed with the CanvasSnapshot system expression. This can then be loaded in to a sprite or tiled background, sent to a server, or opened with the Browser object in a new tab.

General

Create object
Create a new instance of an object type on a layer at a given position. If a Family is chosen, a random object type from the family is picked, and an instance created for that.

Go to layout
Go to layout (by name)
Switch to another layout in the project. Note that global variables keep their current value - they are not reset. To reset them use the system action Reset global variables.

Go to next/previous layout
Switch to the next or previous layout in the project. The order as they appear in the Project Bar is used, where layouts at the top are first and layouts at the bottom are last. If on the first layout, trying to go to the previous layout does nothing, and if on the last layout, trying to go to the next layout does nothing. Note that global variables keep their current value - they are not reset. To reset them use the system action Reset global variables.

Restart layout
Restart the current layout. Note that unlike Go to layout, this action resets all event groups to their initial activation state. Global variables keep their current value - they are not reset. To reset them use the system action Reset global variables.

Set group active
Set an event group active or inactive. None of the events in an inactive group run until it is activated again. The event group is identified by its name.

Sort Z order
Sort the Z order of instances of a given object according to an instance variable. This effectively removes all instances from their Z order, sorts them, then inserts the sorted sequence back in to the holes left behind. This means if the instances are spread across a range of layers, they will be sorted in the same Z order locations, maintaining the same order relative to other instances on those layers. Note this action is much faster than using an ordered For each with an action like Send to front/back, so this action should be the preferred way to sort the Z order of large numbers of instances.

Stop loop
Stop a Repeat, For or For each loop currently running. These loops are system conditions. The rest of the event's actions and subevents will still complete, but the loop will not run any further after that.

Global & local variables

Add to
Subtract from
Set value
Alter the value stored by a global or local variable.

Reset global variables
Reset all the global variables in the project to their initial value.

Layers & Layout

For more information about the effect actions, see Effects.

Recreate initial objects
Recreate the objects in a rectangular area of the layout as they appear in the Layout View. In other words, this restores a section of the initial level design. Note that this does not destroy any existing objects, so if used repeatedly will create multiple objects sitting on top of each other. Only objects of the given type are created, or alternatively a family can be passed and all objects belonging to that family are recreated.

Reset persisted objects
Across the entire project, reset all objects using the Persist behavior to their initial state (as if the layout has not been visited yet). This is useful when restarting a new game from the beginning again.

Set layer angle
Rotate an entire layer by a number of degrees.

Set layer background color
Set the background color of a layer. Note if the layer is transparent, setting the background won't change the appearance unless you also make the layer opaque.

Set layer blend mode
Set the blend mode of a layer. See the Effects section for a description of the available blend modes.

Set layer effect enabled
Enable or disable one of the effects added to a layer on the current layout. This action cannot be used to alter layers from other layouts.

Set layer force own texture
Change a layer's Force own texture property at runtime. For more information see the property in the Layers manual entry.

Set layer effect parameter
Change the value of one of the parameters for an effect added to a layer on the current layout. This action cannot be used to alter layers from other layouts. The parameter to change is specified by its zero-based index, i.e. 0 to change the first parameter, 1 to change the second parameter, and so on.

Set layer opacity
Set the opacity (or semitransparency) of an entire layer.

Set layer parallax
Set the horizontal and vertical parallax rates of a layer.

Set layer scale
Set the scale (or zoom) of an entire layer, taking in to account its scale rate property.

Set layer scale rate
Set the scale rate property of a layer, which affects how quickly it scales (if at all).

Set layer transparent
Set the transparent property of a layer. If transparent, the background color is ignored and other layers can appear beneath it.

Set layer visible
Show or hide an entire layer.

Set layout angle
Rotate an entire layout by a number of degrees. This rotates all the layers in the layout.

Set layout effect enabled
Enable or disable one of the effects added to the current layout. This action cannot be used to alter other layouts.

Set layout effect parameter
Change the value of one of the parameters for an effect added to the current layout. This action cannot be used to alter other layouts. The parameter to change is specified by its zero-based index, i.e. 0 to change the first parameter, 1 to change the second parameter, and so on.

Set layout scale
Set the scale (or zoom) of an entire layout. This scales all the layers in the layout, taking in to account their scale rate property.

Save & Load

Load
Load the state of the game from a save slot. When done, triggers On load complete, or On load failed if the save slot has not been saved to before. For more information see How to make savegames.

Load from JSON
Load the state of the game from a string of JSON data previously returned by the SaveStateJSON system expression. For more information see How to make savegames.

Save
Save the state of the game to a save slot. When done, triggers On save complete. For more information see How to make savegames.

Scrolling

To scroll, the size of the layout must be bigger than the size of the window, or the layout's Unbounded scrolling property must be set to Yes. Otherwise there is nowhere to scroll to and scrolling will have no effect.

Scroll to object
Center the view on a given object. This scrolls all layers taking in to account their parallax property.

Scroll to position
Scroll to X
Scroll to Y
Set the X and Y positions to center the view on. This scrolls all layers taking in to account their parallax property.

Time

Set time scale
Change the rate time passes at in the game. Useful for slow-motion or pausing effects. See the tutorial on Delta-time and framerate independence for more information.

Set object time scale
Restore object time scale
Change the rate time passes for a specific object. This affects the object's behaviors and its own dt expression. Restoring the object's time scale returns it to the same time scale the rest of the game is using. See the tutorial on Delta-time and framerate independence for more information.

Set minimum framerate
Set the maximum delta-time (dt) value based on a framerate. The default minimum framerate is 30 FPS, meaning the maximum dt is 1 / 30 (= 33ms). If the framerate drops below 30 FPS, dt will still not exceed 1/30. This has the effect of the game going in to slow motion as it drops below the minimum framerate, rather than objects stepping further every frame to keep up the same real-world speed. This helps avoid skipped collisions due to stepping a very large distance every frame.

Signal
Resume any events paused with a Wait for signal action with the given tag.

Wait
Wait a number of seconds before continuing on to the next action or sub-events. Other events continue to run in the meantime. See also the tutorial on How to use the System 'Wait' actions.

Wait for signal
Wait indefinitely until the Signal action is used with the same tag. Other events continue to run in the meantime. See also the tutorial on How to use the System 'Wait' actions.

Tags: