Scene Locking - coldrockgames/gml-raptor GitHub Wiki

In every game, sooner or later, the situation arises where you want to "lock" the scene (i.e. "no mouse or keyboard input please, game is busy") like during load or save.

This is often a very complicated task, especially if you didn't prepare for it from the first moment on.

With raptor, a comfortable solution to this problem is at hand:

set_scene_locked
set_scene_unlocked

There's a pair of global function available which lets you lock the entire screen.

  • No mouse events
  • No keyboard events

will reach your controls and game objects (as long as they are a child of _raptorBase).

These functions also send a broadcast, RAPTOR_BROADCAST_SCENE_LOCKED and RAPTOR_BROADCAST_SCENE_UNLOCKED respectively.

/// @func	set_scene_locked(_lock_mouse = true, _lock_keyboard = true)
/// @desc	Set the entire scene in a "lock" state. This means, mouse and keyboard
///			will not be able to perform any kind of event (click, enter/leave, hover, hotkeys, etc).
///			You may lock only mouse or only keyboard through the two arguments.
function set_scene_locked(_lock_mouse = true, _lock_keyboard = true) {
/// @func	set_scene_unlocked(_unlock_mouse = true, _unlock_keyboard = true)
/// @desc	The counterpart to set_scene_locked.
///			Re-enable the mouse and keyboard.
///			NOTE: The arguments are named "_unlock_*". Supply TRUE to UNLOCK them!
function set_scene_unlocked(_unlock_mouse = true, _unlock_keyboard = true) {

If you created objects that are not part of the inheritance chain of raptor objects, they will not be locked. The locking mechanism of raptor works for all StatefulObjects and for all UI controls (i.e. children of _baseControl).

Note

The locking only keeps your scene from receiving input events! Animations, broadcasts, sprite broadcasts, network traffic and all other external parallel things running in your game are not affected by scene locking. It's just a full input lock.

⚠️ **GitHub.com Fallback** ⚠️