Hello and welcome on the main documentation of the sxgd plugin.
It’s also my first attempt at AsciiDoc.

The plugin contains extensions, modules, and nodes.

Note
Each class is prefixed by Sx for namespacing concerns.

Installing

The plugin needs to be available in the ./addons/sxgd folder.

If you have Git, it is best installed as a Git submodule, using the following command in your Godot project directory:

git clone https://github.com/Srynetix/sxgd ./addons/sxgd

If not, you can directly unzip the plugin code in the ./addons/sxgd folder.

Usage

You can use extensions by referring to their names, so the following code will work:

MyCustomNode.gd
# A custom node of your project
extends Node

# Example: use the SxLog facility
var logger := SxLog.get_logger("MyNode")

func _ready() -> void:
    # Example: generate a random color with a custom alpha value as a float
    var my_color := SxColor.rand_with_alpha_f(0.5)

    # Example: generate a random value
    logger.info(SxRand.range_i(0, 10))

For most nodes and modules, you can directly drag’n’drop them, or inherit them, but there is one thing you can’t do: you can’t use them as autoloads. Well, you can, but not directly.

Global classes and autoloads

Each sxgd class declares a class_name attribute, to register them as global classes (needed to avoid importing each file using its path, which is quickly unreliable/unmaintainable).

Due to Godot/GDScript quirks, you cannot give a class_name to an autoloaded Node, because autoloads can be accessed globally. So you cannot directly use sxgd nodes as autoloads…​

But! What you can do is: subclass them in a new class, through inheritance, not giving it a class_name, and use this node as an autoload.

Here is a quick example for the SxGameData node, useful for most projects (state handling & persistable key-value store).

  1. Create a specific GameData.gd script for your game (personally, I put autoloads in a top-level autoloads folder).

  2. In this script, put at the top extends SxGameData (it will automatically resolves the path to the original class). In this file to can override anything you want and add new functionalities.

    GameData.gd
    extends SxGameData
    
    func _ready() -> void:
        # Note: _logger is a SxLog.Logger exposed in SxGameData.
        _logger.info("Game data loaded!")
  3. In Godot, in the Project settings  Autoloads menu, add your GameData.gd script as an autoload, with the Global variable checkbox enabled.

  4. And that’s it! In your game code, you can refer to GameData (instead of SxGameData) to access your autoload!

Now a second example, SxSceneTransitioner, useful to fade between game screens.

  1. Create a new GameSceneTransitioner.gd script, and extend SxSceneTransitioner.

  2. In Godot, in the Project settings  Autoloads menu, add your GameSceneTransitioner.gd script as an autoload, with the Global variable checkbox enabled.

  3. And that’s it! In your game code, you can refer to GameSceneTransitioner to access your autoload!

Contents

This section contains all of the components included in the plugins, with a short description. Click on the component name to access its specific documentation.

Extensions

Static methods and related utilities for any relevant part of Godot Engine.

  • SxArray: Array helpers (string trimming, …​).

  • SxBuffer: Buffer helpers (zstd compression, …​).

  • SxColor: Color helpers (applying an alpha value on an existing color, generating a random color, …​).

  • SxContainer: Generic container (Array, Dictionary) helpers (equality checks, …​).

  • SxInput: Input helpers (extract joystick movement from 4 joystick actions, …​).

  • SxJson: JSON helpers (read file, write file, …​).

  • SxLog: Log facility (get/create a logger, set a log level, …​).

  • SxMath: Additional math functions (lerp a Vector3, align a transform with an axis, …​).

  • SxNetwork: Network helpers (UUID generation, network shortcuts, …​).

  • SxNode: Generic Node methods (print tree to string, …​).

  • SxOs: Generic OS methods (check if OS is mobile, set window size from string, …​).

  • SxRand: Additional rand methods (rand range with ints, random choice in array, …​).

  • SxShader: Shader helpers (shortcuts to get/set a shader param, …​).

  • SxText: Text helpers (case conversion, …​).

  • SxTileMap: Tilemap helpers (get cell rotation, dump/restore, …​).

  • SxUi: Control-related helpers (get default font, …​).

Modules

Specific modules separated from the rest.

FontAwesome icons integration

  • SxFaButton: Ready-to-use Button with an integrated FontAwesome icon.

  • SxFaFont: Font management wrapper around FontAwesome, useful for specific needs.

  • SxFaLabel: A label which display a FontAwesome icon.

Scene Runner

  • SxSceneRunner: Useful as a kind of "test suite" where you can select any scene from a specific folder, with on-screen navigation.

Virtual Controls

A customizable virtual control module (includes assets by Kenney, and ready-to-use samples):

Nodes

Reusable nodes, organized in multiple categories.

Audio

Audio nodes.

Debug

Debug nodes.

  • SxDebugTools: Useful global debug UI, showing multiple panels:

    • Debug info: shows performance info at the top-left section of the screen

    • Log details: scrollable logs (only those printed with SxLog, not print)

    • Node tracer: show currently enabled node tracers (see SxNodeTracer)

    • Scene tree dumps: show nodes currently in the scene tree, with support for the scene tree embedded in the SxListenServerPeer node.

    • In-game console: execute commands to interact with the game (see SxDebugConsole).

  • SxNodeTracer: Node parameter tracing system.

FX

Nodes concerning special effects / shaders / particles.

Input

Input nodes.

Networking

Networking-related and multiplayer-related nodes.

  • SxClientPeer: A generic client peer implementation.

  • SxClientRpc: Generic client RPC methods (synchronized scene spawning, …​).

  • SxListenServerPeer: A ready-to-use listen server, to use a client/server combo on a same game instance.

  • SxRpcService: Wraps the client and server RPC methods, and the input synchronization.

  • SxServerPeer: A generic server peer implementation.

  • SxServerRpc: Generic server RPC methods (send input, update username, …​).

  • SxSyncBarrier: Useful system to wait for all clients to do something.

  • SxSyncInput: Input synchronization system, using one SxSyncPeerInput per connected client.

  • SxSyncPeerInput: Specific input status for a client (uses the input map, configurable with a ProjectSettings value)

UI

Control-related nodes.

Utils

Miscellaneous nodes.

  • SxCmdLineParser: Simple node which handles command-line arguments, needs to be overriden.

  • SxCVars: Console variables, pluggable in the SxDebugConsole.

  • SxGameData: A general-purpose in-memory (and on-disk) key-value store, to be used through inheritance and autoload.

  • SxLoadCache: A resource/scene loader, exposing a load_resources method to implement through inheritance and autoload. Useful to load every needed resources at game startup.

  • SxSceneTransitioner: A simple scene transition node, with a fade-in/fade-out effect, to be used with inheritance as autoload.

Classes

SxArray

Inherits: Reference

Array helpers.

Description

Generic array helpers.

Methods

Array

static trim_strings ( Array array )

Method Descriptions

  • static Array trim_strings ( Array array )

    Trim whitespace on each strings from a string array.

Example
var strings := ["  a", " b ", "c   "]
var trimmed_strings := SxArray.trim_strings(strings)
# => ["a", "b", "c"]

SxAudioStreamPlayer

Inherits: Node

Audio player with multiple simultaneous voices.

Description

An audio player with multiple simultaneous voices, configurable through the max_voices parameter.

Methods

void

play_stream ( AudioStream stream )

void

play_stream_on_voice ( String key, int voice )

void

play_key ( String key )

void

play_key_on_voice ( String key, int voice )

void

fade_in_on_voice ( int voice, float duration = 0.5 )

void

fade_out_on_voice ( int voice, float duration = 0.5 )

void

set_volume_on_voice ( int voice, float volume )

float

get_volume_on_voice ( int voice )

AudioStreamPlayer

get_voice ( int voice )

Property Descriptions

  • int max_voices

    Maximum simultaneous voices.

  • String audio_bus_output

    Audio bus output.

  • Dictionary streams

    Audio streams to play, indexed by name.

  • float initial_volume_db

    Initial volume for each audio players.

Method Descriptions

  • void play_stream ( AudioStream stream )

    Play an audio stream on an auto-selected voice.

  • void play_stream_on_voice ( String key, int voice )

    Play an audio stream on a specific voice.

  • void play_key ( String key )

    Play a stored audio stream by key on an auto-selected voice.

  • void play_key_on_voice ( String key, int voice )

    Play a stored audio stream by key on a specific voice.

  • void fade_in_on_voice ( int voice, float duration = 0.5 )

    Apply a "fade in" effect on a voice for a duration in seconds.

  • void fade_out_on_voice ( int voice, float duration = 0.5 )

    Apply a "fade out" effect on a voice for a duration in seconds.

  • void set_volume_on_voice ( int voice, float volume )

    Set the volume on a specific voice.

  • float get_volume_on_voice ( int voice )

    Get the volume on a specific voice.


SxBuffer

Inherits: Reference

Buffer helpers.

Description

Generic buffer helpers.

Method Descriptions

The content size is needed for Godot to decompress, so the resulting byte array is not valid zstd compressed data. To have a valid zstd compressed data, you need to strip the first 64 bits.

It is not usable with zstd compressed data generated elsewhere, because it expects a 64 bit integer at first representing the original data size (needed for Godot).


SxCVars

Inherits: Node

Console vars.

Description

Console vars, a dynamic key-value store bindable to the SxDebugConsole.

It’s a little special to use, so here’s a quick tutorial to implement custom CVars.

  1. Create a new script (as an autoload), inheriting from SxCVars.

  2. Create a class, extending from Object, with your list of variables as attributes.

extends SxCVars

# Declare your class containing your console vars.
class _Vars:
    extends Object

    var test_boolean := false
    var test_string := "hello"
    var test_integer := 1
    var test_float := 2.5

func _init() -> void:
    # This line will register the vars
    _vars = _Vars.new()

    # This line will bind the SxDebugConsole with the vars so you can use
    # cvar_list / cvar_set / cvar_get commands
    SxDebugConsole.bind_cvars(self)

Methods

Variant

get_cvar ()

void

set_cvar ( String name, Variant value )

String

print_cvars ()

Method Descriptions

  • Variant get_cvar ()

    Get a console variable value.

  • void set_cvar ( String name, Variant value )

    Set a console variable from its name and a value.

  • String print_cvars ()

    Build a list of each known CVars with their values.


SxClientPeer

Inherits: Node

Configurable network peer, client side.

Description

Configurable network peer, client side.

Signals

  • connected_to_server ()

    On successful connection to the target server.

  • connection_failed ()

    On failed connection to the target server.

  • server_disconnected ()

    On server disconnection.

  • players_updated ( Dictionary players )

    On players data update (for example a username change).

Methods

Dictionary

get_players ()

Property Descriptions

  • String server_address

    Target server address.

  • int server_port

    Target server port.

  • bool use_websockets

    Use a WebSockets client (instead of ENet).

Method Descriptions

  • Dictionary get_players ()

    Get known players data.


SxClientRpc

Inherits: Node

Client RPC interface.

Description

Client RPC interface.

Signals

  • spawned_from_server ( Node node )

    When a node was spawn from the server request.

  • removed_from_server ( Node node )

    When a node was removed from the server request.

  • players_updated ( Dictionary players )

    On players data update (for example a username change).

Methods

void

pong ( int peer_id )

void

spawn_synchronized_scene_on ( int peer_id, NodePath parent, String name, String scene_path, String guid, int owner_peer_id, Dictionary master_configuration )

void

spawn_synchronized_scene_broadcast ( NodePath parent, String name, String scene_path, String guid, int owner_peer_id, Dictionary master_configuration )

void

synchronize_node_broadcast ( NodePath path, Dictionary data )

void

remove_synchronized_node_on ( int peer_id, NodePath path )

void

remove_synchronized_node_broadcast ( NodePath path )

void

synchronize_players_broadcast ( Dictionary players )

Method Descriptions

  • void pong ( int peer_id )

    Send a "pong" event to a specific peer.

  • void spawn_synchronized_scene_on ( int peer_id, NodePath parent, String name, String scene_path, String guid, int owner_peer_id, Dictionary master_configuration )

    Spawn a synchronized node on a specific peer.

  • void spawn_synchronized_scene_broadcast ( NodePath parent, String name, String scene_path, String guid, int owner_peer_id, Dictionary master_configuration )

    Spawn a synchronized node on all peers.

  • void synchronize_node_broadcast ( NodePath path, Dictionary data )

    Synchronize data from a specific node on all peers.

  • void remove_synchronized_node_on ( int peer_id, NodePath path )

    Remove a synchronized node on a specific peer.

  • void remove_synchronized_node_broadcast ( NodePath path )

    Remove a synchronized node on all peers.

  • void synchronize_players_broadcast ( Dictionary players )

    Synchronize players data on all peers.


SxCmdLineParser

Inherits: Node

Simple command-line parser.

Description

Simple command-line parser.

Inherit the node as an autoload and handle your custom command-line arguments by redeclaring the method _handle_args.

Methods

void

_handle_args ( SxCmdLineParser.Args args )

Method Descriptions

  • void _handle_args ( SxCmdLineParser.Args args )

    Override this method to handle command-line arguments.

SxCmdLineParser.Args

Inherits: Object

Description

No description.

Properties

Array

positional

None

Dictionary

options

None

Property Descriptions

  • Array positional

    Positional arguments.


SxColor

Inherits: Reference

Color helpers.

Description

Generic color helpers.

Methods

Color

static with_alpha_f ( Color color, float alpha )

Color

static with_alpha_i ( Color color, int alpha )

Color

static rand ()

Color

static rand_with_alpha_f ( float alpha )

Color

static rand_with_alpha_i ( int alpha )

Method Descriptions

  • static Color with_alpha_f ( Color color, float alpha )

    Apply a floating-point alpha value on a color (between 0 and 1).

Example
# Creates a semi-transparent "aqua" color
var c := SxColor.with_alpha_f(Color.aqua, 0.5)
  • static Color with_alpha_i ( Color color, int alpha )

    Apply an integer alpha value on a color (between 0 and 255).

Example
# Creates a semi-transparent "aqua" color
var c := SxColor.with_alpha_i(Color.aqua, 127)
  • static Color rand ()

    Generate a random color without transparency.

Example
var c := SxColor.rand()
  • static Color rand_with_alpha_f ( float alpha )

    Generate a random color with a floating-point alpha value (between 0 and 1).

Example
var c := SxColor.rand_with_alpha_f(0.5)
  • static Color rand_with_alpha_i ( int alpha )

    Generate a random color with a integer alpha value (between 0 and 255).

Example
var c := SxColor.rand_with_alpha_f(0.5)

SxContainer

Inherits: Reference

Container helpers.

Description

Generic container helpers.

Methods

bool

static are_values_equal ( Variant v1, Variant v2 )

bool

static are_dictionaries_equal ( Dictionary d1, Dictionary d2 )

bool

static are_arrays_equal ( Array a1, Array a2 )

Method Descriptions

  • static bool are_values_equal ( Variant v1, Variant v2 )

    Check deep-equality between two values.

Example
var obj1 := {"one": 1, "two": [1, 2]}
var obj2 := {"one": 1, "two": [1, 2]}
var obj3 := {"one": 1, "two": [1, 2, 3]}

SxContainer.are_values_equal(obj1, obj2)    # => true
SxContainer.are_values_equal(obj1, obj3)    # => false
Example
var obj1 := {"one": 1, "two": [1, 2]}
var obj2 := {"one": 1, "two": [1, 2]}
var obj3 := {"one": 1, "two": [1, 2, 3]}

SxContainer.are_dictionaries_equal(obj1, obj2)    # => true
SxContainer.are_dictionaries_equal(obj1, obj3)    # => false
  • static bool are_arrays_equal ( Array a1, Array a2 )

    Check deep-equality between two arrays.

Example
var obj1 := [1, 2]
var obj2 := [1, 2]
var obj3 := [1, 2, 3]

SxContainer.are_arrays_equal(obj1, obj2)    # => true
SxContainer.are_arrays_equal(obj1, obj3)    # => false

SxDebugConsole

Inherits: MarginContainer

Interactive in-game console.

Description

Interactive in-game console.

SxDebugConsole

Methods

void

static bind_cvars ( SxCVars vars )

Method Descriptions

  • static void bind_cvars ( SxCVars vars )

    Bind a SxCVars instance to allow the console to manipulate console vars.


SxDebugTools

Inherits: CanvasLayer

Global debug tools, showing debug information.

Description

Global debug tools, showing debug information:

  • Debug info: shows performance info at the top-left section of the screen

  • Log details: scrollable logs (only those printed with SxLog, not print)

  • Node tracer: show currently enabled node tracers (see SxNodeTracer)

  • Scene tree dumps: show nodes currently in the scene tree, with support for the scene tree embedded in the SxListenServerPeer node

  • In-game console: execute commands to interact with the game (see SxDebugConsole)

SxDebugTools

Enumerations

enum SxDebugTools.PanelType:

  • DEBUG_INFO = 0 --- Debug info panel.

  • LOG = 1 --- Log panel.

  • NODE_TRACER = 2 --- Node tracer panel.

  • SCENE_TREE_DUMP = 3 --- Scene tree dump panel.

Methods

void

show ()

void

hide ()

void

toggle ()

void

show_specific_panel ( SxDebugTools.PanelType panel_type )

Method Descriptions

  • void show ()

    Show the debug tools.

  • void hide ()

    Hide the debug tools.

  • void toggle ()

    Toggle the debug tools visibility.

  • void show_specific_panel ( SxDebugTools.PanelType panel_type )

    Show a specific panel type.

    If the main panel is hidden, nothing will be shown so you need to also call show.


SxDoubleTap

Inherits: Node

Double-tap detector.

Description

Double-tap detector, useful for mobile environments.

Signals

  • doubletap ( int touch_idx )

    Event emitted on double-tap.

Property Descriptions

  • int threshold_ms

    Detection threshold value in milliseconds.

  • bool should_process_input

    Disable this if the tap detector should process input or not.

  • Rect2 target_tect

    Only detect double-tap on this surface. Detect anywhere on screen if set to zero.


SxFaButton

Inherits: Button

FontAwesome button, displaying an icon.

Description

FontAwesome button, displaying an icon.
Make sure you read the docs about JSON before using the component.

SxFaButton

Properties

String

icon_name

anchor

int

icon_size

24

Color

icon_color

#ffffff

float

icon_rotation

0.0

Property Descriptions

  • int icon_size

    Icon size.

  • Color icon_color

    Icon color.

  • float icon_rotation

    Icon rotation.


SxFaFont

Inherits: Reference

Font management wrapper around FontAwesome.

Description

Font management wrapper around FontAwesome.
Make sure you read the docs about JSON before using the component.

Methods

DynamicFont

static create_fa_font ( int family, int size )

int

static get_icon_code ( String name )

Method Descriptions

  • static DynamicFont create_fa_font ( int family, int size )

    Lazily create a FontAwesome font, using a specific font family and a size.

    If the font already exists, it will be returned.
    If not, it will be created.

  • static int get_icon_code ( String name )

    Get the icon unicode code point from its string representation.


SxFaLabel

Inherits: Label

FontAwesome label, used to easily display a FontAwesome icon.

Description

FontAwesome label, used to easily display a FontAwesome icon.
Make sure you read the docs about JSON before using the component.

Properties

String

icon_name

anchor

int

icon_size

24

Color

icon_color

#ffffff

Property Descriptions

  • int icon_size

    Icon size.

  • Color icon_color

    Icon color.


SxFadingRichTextEffect

Inherits: RichTextEffect

A per-character fade-in effect.

Description

A per-character fade-in effect.

Properties

String

bbcode

sxgd-fadein

Property Descriptions

  • String bbcode

    Exposed BBCode.


SxFadingRichTextLabel

Inherits: RichTextLabel

A wrapped RichTextLabel with a per-character fade-in effect.

Description

A wrapped RichTextLabel with a per-character fade-in effect.

SxFadingRichTextLabel

Signals

  • shown ()

    Text was completely shown.

Enumerations

enum SxFadingRichTextLabel.Alignment:

  • LEFT = 0 --- Left align.

  • RIGHT = 1 --- Right align.

Properties

bool

autoplay

false

float

char_delay

0.1

float

fade_out_delay

2.0

SxFadingRichTextLabel.Alignment

text_alignment

SxFadingRichTextLabel.Alignment.LEFT

Methods

void

fade_in ()

void

update_text ( String text )

Property Descriptions

  • bool autoplay

    Autoplay the text animation.

  • float char_delay

    Delay per character, in seconds.

  • float fade_out_delay

    Fade out delay, in seconds.

Method Descriptions

  • void fade_in ()

    Start the "fade in" animation.

  • void update_text ( String text )

    Update text to display and reset the animation.
    It will not automatically replay the animation, even with autoplay set.

Example
var label := $MyLabel as SxFadingRichTextLabel
label.update_text("Hello!")
label.fade_in()

SxFullScreenAcceptDialog

Inherits: SxFullScreenDialog

A full-screen accept dialog, useful for mobile environment.

Description

A full-screen accept dialog, useful for mobile environment.

SxFullScreenAcceptDialog

Signals

  • confirmed ()

    On user confirmation.

Properties

String

message

Message.

String

ok_message

OK

Property Descriptions

  • String ok_message

    Message for the OK button.


SxFullScreenConfirmationDialog

Inherits: SxFullScreenDialog

A full-screen confirmation dialog, useful for mobile environment.

Description

A full-screen confirmation dialog, useful for mobile environment.

SxFullScreenConfirmationDialog

Signals

  • confirmed ()

    On user confirmation.

  • canceled ()

    On user cancellation.

Properties

String

message

Are you sure?

Property Descriptions

  • String message

    Confirmation message.


SxFullScreenDialog

Inherits: Panel

A full-screen dialog, useful for mobile environment.

Description

A full-screen dialog, useful for mobile environment.

Properties

String

title

Dialog title

bool

autohide

true

bool

show_title

true

Methods

void

show ()

void

hide ()

Property Descriptions

  • bool autohide

    Autohide the dialog on action.

  • bool show_title

    Show the dialog title.

Method Descriptions

  • void show ()

    Show the dialog.

  • void hide ()

    Hide the dialog.


SxFullScreenFileDialog

Inherits: SxFullScreenDialog

A full-screen file selection dialog, useful for mobile environment.

Description

A full-screen file selection dialog, useful for mobile environment.
Uses SxItemList and SxDoubleTap.

SxFullScreenFileDialog

Signals

  • canceled ()

    On user cancellation.

  • file_selected ( String file )

    On file selected.

Enumerations

enum SxFullScreenFileDialog.Mode:

  • OPEN_FILE = 0 --- Open mode.

  • SAVE_FILE = 1 --- Save mode.

Methods

void

invalidate ()

Property Descriptions

  • String file_filter

    File filter.

Method Descriptions

  • void invalidate ()

    Reset the selection status.

SxFullScreenFileDialog.PathShortcut

Inherits: Object

Description

Path shortcut displayed in the dialog.

Properties

String

name

None

String

path

None

Methods

SxFullScreenFileFialog.PathShortcut

from_dict ( Dictionary d )

Property Descriptions

Method Descriptions

  • SxFullScreenFileFialog.PathShortcut from_dict ( Dictionary d )

    Build a shortcut from JSON data.


SxFxBetterBlur

Inherits: Control

A ready-to-use gaussian blur, compatible with GLES2.

Description

A ready-to-use gaussian blur, compatible with GLES2.

SxFxBetterBlur

Properties

float

strength

None

Property Descriptions

  • float strength

    Blur strength.


SxFxCamera

Inherits: Camera2D

A custom 2D camera with included effects.

Description

A custom 2D camera with included effects.

Enumerations

enum SxFxCamera.Direction:

  • LEFT = 0 --- Left direction.

  • RIGHT = 1 --- Right direction.

  • UP = 2 --- Up direction.

  • DOWN = 3 --- Down direction.

Methods

void

tween_to_position ( Vector2 position, float speed = 0.5, float zoom = 1, int easing = Tween.TRANS_QUAD )

void

viewport_scroll ( Vector2 top_left, SxFxCamera.Direction direction, float speed = 0.65, int easing = Tween.TRANS_QUAD )

void

reset_limits ()

void

set_limit_from_rect ( Rect2 rect )

Property Descriptions

  • float max_shake_strength

    Max screen shake strength.

  • float shake_ratio

    Shake ratio.

Method Descriptions

  • void tween_to_position ( Vector2 position, float speed = 0.5, float zoom = 1, int easing = Tween.TRANS_QUAD )

    Tween the camera to a specific position.

  • void viewport_scroll ( Vector2 top_left, SxFxCamera.Direction direction, float speed = 0.65, int easing = Tween.TRANS_QUAD )

    Play a viewport scroll effect (quickly scroll to the "next screen").

  • void reset_limits ()

    Reset the camera limits to arbitrary large values.

  • void set_limit_from_rect ( Rect2 rect )

    Set the camera limits from Rect2 values.


SxFxChromaticAberration

Inherits: ColorRect

A simple chromatic aberration effect.

Description

A simple chromatic aberration effect.

SxFxChromaticAberration

Properties

bool

enabled

true

float

amount

1.0

Property Descriptions

  • bool enabled

    Enable/Disable the effect.

  • float amount

    Increase/Decrease the effect force.


SxFxDissolve

Inherits: ColorRect

A ready-to-use dissolve effect.

Description

A ready-to-use dissolve effect.

SxFxDissolve

Properties

float

ratio

0

Color

replacement_color

Color(1, 1, 1, 0)

float

noise_period

64.0

Property Descriptions

  • float ratio

    Effect amount (between 0 and 1).

  • Color replacement_color

    Color to use for the dissolved pixels.

  • float noise_period

    Noise period (~= the noise size).


SxFxGrayscale

Inherits: ColorRect

A simple grayscale effect.

Description

A simple grayscale effect.

SxFxGrayscale

Properties

float

ratio

0.0

Property Descriptions

  • float ratio

    Effect amount (between 0 and 1).


SxFxMotionBlur

Inherits: ColorRect

A ready-to-use motion blur.

Description

A ready-to-use motion blur.

SxFxMotionBlur

Properties

float

angle_degrees

None

float

strength

None

Property Descriptions

  • float angle_degrees

    Rotation angle in degrees.

  • float strength

    Blur strength.


SxFxShockwave

Inherits: ColorRect

An animated shockwave effect.

Description

An animated shockwave effect.

SxFxShockwave

Methods

void

start_wave ( Vector2 position )

bool

wave_is_running ()

Property Descriptions

  • float wave_size

    Wave size.

  • float force

    Wave force.

  • float wave_thickness

    Wave thickness.

Method Descriptions

  • void start_wave ( Vector2 position )

    Start the wave animation at a specific position.

  • bool wave_is_running ()

    Check if the wave animation is running.


SxFxVignette

Inherits: ColorRect

A vignette effect.

Description

A vignette effect.

SxFxVignette

Properties

float

vignette_size

10.0

float

vignette_ratio

0.25

Methods

void

fade ( float duration = 1.0 )

Property Descriptions

  • float vignette_size

    Vignette size.

  • float vignette_ratio

    Vignette ratio.

Method Descriptions

  • void fade ( float duration = 1.0 )

    Start a fading animation.


SxGameData

Inherits: Node

A general-purpose in-memory key-value store, to be used through inheritance and autoload.

Description

A general-purpose in-memory key-value store, to be used through inheritance and autoload.

Properties

String

default_file_path

None

Methods

void

store_value ( String name, Variant value, String category = default )

Variant

load_value ( String name, Variant orDefault = null, String category = default )

void

store_static_value ( String name, Variant value, String category = default )

Variant

load_static_value ( String name, Variant orDefault = null, String category = default )

void

store_temporary_value ( String name, Variant value, String category = default )

Variant

load_temporary_value ( String name, Variant orDefault = null, String category = default )

int

increment ( String name, String category = default )

int

decrement ( String name, String category = default )

bool

has_value ( String name, String category = default )

bool

remove ( String name, String category = default )

void

persist_to_disk ( String path )

void

load_from_disk ( String path )

void

clear_all ()

void

clear_category ( String category )

String

dump_all ()

String

dump_category ( String category )

Property Descriptions

  • String default_file_path

    Default file path used in the persist_to_disk and load_from_disk methods.

Method Descriptions

  • void store_value ( String name, Variant value, String category = default )

    Store value in game data.

    Example
    my_data.store_value("key", 123)
    my_data.store_value("key2", "hello")
    my_data.store_value("key3", "hello", "my_category")
  • Variant load_value ( String name, Variant orDefault = null, String category = default )

    Load value from game data.

    Example
    var levels = data.load_value("levels", Dictionary())  # returns a new Dictionary if key is missing
    var levels2 = data.load_value("my_data", Dictionary(), "my_category")
  • void store_static_value ( String name, Variant value, String category = default )

    Store static value in game data.
    Static data is not persisted to disk.

    Example
    my_data.store_static_value("levels", json_levels)
    my_data.store_static_value("my_data", my_data, "my_category")
  • Variant load_static_value ( String name, Variant orDefault = null, String category = default )

    Load static value from game data.
    Static data is not persisted to disk.

    Example
    var levels = data.load_static_value("levels", Dictionary())  # returns a new Dictionary if key is missing
    var levels2 = data.load_static_value("my_data", Dictionary(), "my_category")
  • void store_temporary_value ( String name, Variant value, String category = default )

    Store temporary value in game data.
    Temporary data is not persisted to disk.

    Example
    my_data.store_temporary_value("foo", "bar")
    my_data.store_temporary_value("foo", "bar", "my_category")
  • Variant load_temporary_value ( String name, Variant orDefault = null, String category = default )

    Load temporary value from game data.
    Temporary data is not persisted to disk.

    Example
    var tmp = data.load_temporary_value("foo")
    var tmp2 = data.load_temporary_value("foo", "default", "my_category")  # returns the "default" string if key is missing
  • int increment ( String name, String category = default )

    Increment a key and returns the value.
    Starts from 0 if the key does not exist.

    Example
    var value := data.increment("key")
    var value2 := data.increment("key", "my_category")
  • int decrement ( String name, String category = default )

    Decrement a key and returns the value.
    Starts from 0 if the key does not exist.

    Example
    var value := data.decrement("key")
    var value2 := data.decrement("key", "my_category")
  • bool has_value ( String name, String category = default )

    Test if game data contains a key.

    Example
    var exists := data.has_value("key")
    var exists2 := data.has_value("key", "my_category")
  • bool remove ( String name, String category = default )

    Remove a key from game data.
    Returns true if the key was found, false if not.

    Example
    data.remove("key")
    data.remove("key", "my_category")
  • void persist_to_disk ( String path )

    Persist game data to disk at a specific path.
    If no path is given to the method, it will uses the default_file_path attribute.

    Example
    data.persist_to_disk()
    data.persist_to_disk("user://my_path.dat")
  • void load_from_disk ( String path )

    Load game data from disk at a specific path.
    If no path is given to the method, it will uses the default_file_path attribute.

    Example
    data.load_from_disk()
    data.load_from_disk("user://my_path.dat")
  • void clear_all ()

    Clear all non-static data.

  • void clear_category ( String category )

    Clear all non-static data for a specific category.

  • String dump_all ()

    Dump each variable to string.

  • String dump_category ( String category )

    Dump each variable to string for a specific category.


SxInput

Inherits: Reference

Input helpers.

Description

Generic input helpers.

Methods

Vector2

static get_joystick_movement ( String action_name )

Method Descriptions

  • static Vector2 get_joystick_movement ( String action_name )

    Get the joystick movement as a Vector2 from four joystick actions in the Input Map. You need to define four joystick actions, each ending with its direction.

For example, if you want to handle a joystick action named move, you need to register: - move_left, move_right, move_up, move_down

Or if your joystick action is named aim: - aim_left, aim_right, aim_up, aim_down

Example
# If `aim_up` strength is 0.5 and `aim_left` strength is 0.5 for example
var movement := SxInput.get_joystick_movement("aim")
# => movement = Vector2(-0.5, 0.5)

SxItemList

Inherits: ItemList

A touch-compatible ItemList.

Description

A touch-compatible ItemList.
From https://github.com/godotengine/godot-proposals/issues/2429


SxJson

Inherits: Reference

JSON helpers.

Description

Generic JSON helpers.

Methods

Variant

static read_json_file ( String path )

Variant

static read_json_from_open_file ( File file )

void

static write_json_file ( Variant json, String path )

Method Descriptions

  • static Variant read_json_file ( String path )

    Read contents from a JSON file at path path. Errors will be logged in the SxJson logger (see SxLog).

Example
# If in this case you know your JSON is in object form, you can cast it to a Dictionary
var data := SxJson.read_json_file("res://my_json_data.json") as Dictionary
  • static Variant read_json_from_open_file ( File file )

    Read contents from an already opened JSON file. Errors will be logged in the SxJson logger (see SxLog).

Example
var file := File.new()
var error := file.open("res://my_json_data.json")
if error == OK:
    # Now that the file is opened, you can use the method
    var json_data = SxJson.read_json_from_open_file(file)
  • static void write_json_file ( Variant json, String path )

    Write JSON data at path path. Errors will be logged in the SxJson logger (see SxLog).

Example
var my_data := {"one": 1}
SxJson.write_json_file(my_data, "user://my_data.json")

SxListenServerPeer

Inherits: Node

Configurable network peer, embedded in a SceneTree: a listen server.

Description

Configurable network peer, embedded in a SceneTree: a listen server.

Properties

int

server_port

None

int

max_players

None

bool

use_websockets

None

Property Descriptions

  • int server_port

    Server port.

  • int max_players

    Max players allowed to join.

  • bool use_websockets

    Use a WebSockets server (instead of ENet).

Method Descriptions

  • Node get_server_root ()

    Get the root node from the inner SceneTree.

  • SceneTree get_server_tree ()

    Get the inner SceneTree.


SxLoadCache

Inherits: Node

A resource/scene loader, exposing a load_resources method to implement through inheritance and autoload.

Description

A resource/scene loader, exposing a load_resources method to implement through inheritance and autoload.
Useful to load every needed resources at game startup.

Methods

void

load_resources ()

void

store_scene ( String scene_name, String scene_path )

void

store_resource ( String resource_name, String resource_path )

bool

has_scene ( String scene_name )

bool

has_resource ( String resource_name )

PackedScene

load_scene ( String scene_name )

Resource

load_resource ( String resource_name )

Node

instantiate_scene ( String scene_name )

Method Descriptions

  • void load_resources ()

    Load resources in cache.

    Should be overriden by child classes.

  • void store_scene ( String scene_name, String scene_path )

    Store a scene in the cache from its path.

    Example
    var cache := SxLoadCache.new()
    cache.store_scene("MyScene", "res://my_scene.tscn")
  • void store_resource ( String resource_name, String resource_path )

    Store a resource in the cache from its path.

    Example
    var cache := SxLoadCache.new()
    cache.store_resource("MyResource", "res://my_resource.tres")
  • bool has_scene ( String scene_name )

    Test if the cache has a specific scene registered.

    Example
    var cache := SxLoadCache.new()
    if cache.has_scene("MyScene"):
        print("OK !")
  • bool has_resource ( String resource_name )

    Test if the cache has a specific resource registered.

    Example
    var cache := SxLoadCache.new()
    if cache.has_resource("MyResource"):
        print("OK !")
  • PackedScene load_scene ( String scene_name )

    Load a stored scene.

    Example
    var cache := SxLoadCache.new()
    var scene := cache.load_scene("MyScene")
  • Resource load_resource ( String resource_name )

    Load a stored resource.

    Example
    var cache := SxLoadCache.new()
    var resource := cache.load_resource("MyResource")
  • Node instantiate_scene ( String scene_name )

    Instantiate a stored scene.

    Example
    var cache := SxLoadCache.new()
    var instance := cache.instantiate_scene("MyScene") as MyScene

SxLog

Inherits: Reference

Log facility.

Description

Generic log facility.

Example: MyNode.gd
extends Node

var logger := SxLog.get_logger("MyNode")

func _ready() -> void:
    logger.info("Node is ready!")

func boom() -> void:
    logger.error("Node has exploded!")

Enumerations

enum SxLog.LogLevel:

  • TRACE = 0 --- Trace log level (lower level).

  • DEBUG = 1 --- Debug log level.

  • INFO = 2 --- Info log level.

  • WARN = 3 --- Warning log level.

  • ERROR = 4 --- Error log level.

  • CRITICAL = 5 --- Critical log level (higher level).

Methods

SxLog.Logger

static get_logger ( String name )

void

static configure_log_levels ( String conf )

void

static set_max_log_level ( String name, int level )

Method Descriptions

  • static SxLog.Logger get_logger ( String name )

    Get or create a specific logger by its name.

Example
var logger := SxLog.get_logger("MyLogger")
logger.info("Hello!")
  • static void configure_log_levels ( String conf )

    Configure log levels for each loggers using a configuration string.

Example
SxLog.configure_log_levels("info,my_logger=debug")
# => 1. Default log level for each logger will be "info"
# => 2. But the "my_logger" logger will have its log level to "debug"
  • static void set_max_log_level ( String name, int level )

    Set maximum log level for a specific logger name.

Example
SxLog.set_max_log_level("my_logger", SxLog.LogLevel.WARN)
# => The "my_logger" logger will have its log level to "warn"

SxLog.Logger

Inherits: Reference

Description

Single logger handle.

Properties

String

name

None

int

max_level

None

bool

display_in_console

None

Methods

SxLog.Logger

SxLog.Logger ( String name, int max_level, bool display_in_console )

void

set_max_log_level ( int level )

void

trace ( String message, Array args )

void

debug ( String message, Array args )

void

info ( String message, Array args )

void

warn ( String message, Array args )

void

error ( String message, Array args )

void

critical ( String message, Array args )

void

trace_m ( String method, String message, Array args )

void

debug_m ( String method, String message, Array args )

void

info_m ( String method, String message, Array args )

void

warn_m ( String method, String message, Array args )

void

error_m ( String method, String message, Array args )

void

critical_m ( String method, String message, Array args )

void

trace_mn ( int peer_id, String method, String message, Array args )

void

debug_mn ( int peer_id, String method, String message, Array args )

void

info_mn ( int peer_id, String method, String message, Array args )

void

warn_mn ( int peer_id, String method, String message, Array args )

void

error_mn ( int peer_id, String method, String message, Array args )

void

critical_mn ( int peer_id, String method, String message, Array args )

Property Descriptions

  • String name

    Name of the logger.

  • int max_level

    Max log level.

  • bool display_in_console

    Determine if the logger should display its content in standard console.

Method Descriptions

  • void set_max_log_level ( int level )

    Set max log level for this logger.

  • void trace ( String message, Array args )

    Log a trace message.

  • void debug ( String message, Array args )

    Log a debug message.

  • void info ( String message, Array args )

    Log an info message.

  • void warn ( String message, Array args )

    Log a warning message.

  • void error ( String message, Array args )

    Log an error message.

  • void critical ( String message, Array args )

    Log a critical message.

  • void trace_m ( String method, String message, Array args )

    Log a trace message for a specific method name.

  • void debug_m ( String method, String message, Array args )

    Log a debug message for a specific method name.

  • void info_m ( String method, String message, Array args )

    Log an info message for a specific method name.

  • void warn_m ( String method, String message, Array args )

    Log a warning message for a specific method name.

  • void error_m ( String method, String message, Array args )

    Log an error message for a specific method name.

  • void critical_m ( String method, String message, Array args )

    Log a critical message for a specific method name.

  • void trace_mn ( int peer_id, String method, String message, Array args )

    Log a trace message for a specific peer ID and a method name.

  • void debug_mn ( int peer_id, String method, String message, Array args )

    Log a debug message for a specific peer ID and a method name.

  • void info_mn ( int peer_id, String method, String message, Array args )

    Log an info message for a specific peer ID and a method name.

  • void warn_mn ( int peer_id, String method, String message, Array args )

    Log a warning message for a specific peer ID and a method name.

  • void error_mn ( int peer_id, String method, String message, Array args )

    Log an error message for a specific peer ID and a method name.

  • void critical_mn ( int peer_id, String method, String message, Array args )

    Log a critical message for a specific peer ID and a method name.


SxMath

Inherits: Reference

Math helpers.

Description

Generic math helpers.

Methods

Vector3

static lerp_vector3 ( Vector3 from, Vector3 to, float weight )

Transform

static align_with_y ( Transform transform, Vector3 new_y )

Transform

static interpolate_align_with_y ( Transform transform, Vector3 new_y, float weight )

float

static map ( float value, float istart, float istop, float ostart, float ostop )

Method Descriptions

  • static Vector3 lerp_vector3 ( Vector3 from, Vector3 to, float weight )

    Lerp a Vector3 towards another using a floating-point weight.

Example
var vec3 := SxMath.lerp_vector3(vec1, vec2, 0.25)
Example
var xform := SxMath.align_with_y(transform, Vector3(1, 1, 1))
  • static Transform interpolate_align_with_y ( Transform transform, Vector3 new_y, float weight )

    Align a transform with a Y vector using interpolation.

Example
var xform := SxMath.interpolate_align_with_y(transform, Vector3(1, 1, 1), 0.25)
Example
# Change the value 10 from bounds (0, 10) to bounds (0, 1)
var n := SxMath.map(10, 0, 10, 0, 1)
# => n = 1

# Change the value 5 from bounds (0, 10) to bounds (0, 1)
var n := SxMath.map(5, 0, 10, 0, 1)
# => n = 0.5

SxMusicPlayer

Inherits: Node

A music player, used to play sound tracks during the game.

Description

A music player, used to play sound tracks, to be used through inheritance as an autoload (see [_sxaudiofxplayer]).

Properties

float

global_volume_db

None

Methods

void

fade_in ( float duration = 0.5 )

void

fade_out ( float duration = 0.5 )

void

play_stream ( AudioStream stream )

Property Descriptions

  • float global_volume_db

    Used to query/set the global volume

Method Descriptions

  • void fade_in ( float duration = 0.5 )

    Apply a "fade in" effect on sound with an optional duration in seconds.

Example
# Suppose we have an instance of `SxMusicPlayer` as an autoload named `GameMusicPlayer`.
GameMusicPlayer.fade_in()
  • void fade_out ( float duration = 0.5 )

    Apply a "fade out" effect on sound with an optional duration in seconds.

Example
# Suppose we have an instance of `SxMusicPlayer` as an autoload named `GameMusicPlayer`.
GameMusicPlayer.fade_out()
  • void play_stream ( AudioStream stream )

    Play an audio stream.

Example
# Suppose we have an instance of `SxMusicPlayer` as an autoload named `GameMusicPlayer`.
GameMusicPlayer.play_stream(my_sound)

SxNetwork

Inherits: Reference

Network helpers.

Description

Generic network helpers.

Methods

int

static get_nuid ( Node node, NodePath multiplayer_node_path )

int

static get_sender_nuid ( Node node, NodePath multiplayer_node_path )

bool

static is_root ( Node node, NodePath multiplayer_node_path )

String

static generate_network_name ( String name, String guid )

bool

static is_multiplayer_authority ( Node node, NodePath multiplayer_node_path )

int

static get_multiplayer_authority ( Node node, NodePath multiplayer_node_path )

bool

static is_server ( SceneTree tree, NodePath multiplayer_node_path )

bool

static is_network_enabled ( SceneTree tree, NodePath multiplayer_node_path )

String

static uuid4 ()

Method Descriptions

  • static int get_nuid ( Node node, NodePath multiplayer_node_path )

    Shortcut to get the network unique ID for the scene tree which contains the target node.

Example
# Script for a random node
extends Node

func _ready() -> void:
    # Get the current network ID
    var my_id := SxNetwork.get_nuid(self, NodePath(""))
  • static int get_sender_nuid ( Node node, NodePath multiplayer_node_path )

    Shortcut to get the sender network unique ID for the scene tree which contains the target node.

Example
# Script for a random node
extends Node

@rpc func _on_master_call():
    # Get the sender network ID
    var sender_id := SxNetwork.get_sender_nuid(self, NodePath(""))
  • static bool is_root ( Node node, NodePath multiplayer_node_path )

    Shortcut to check if the current network unique ID is the number 1.

Example
# Script for a random node
extends Node

@rpc func _on_remote_call():
    # Am I root?
    if SxNetwork.is_root(self, NodePath("")):
        print("Yay!")
  • static String generate_network_name ( String name, String guid )

    Generate a network name from a node name and a UUID.

Example
var name = SxNetwork.generate_network_name("MyNode", "60b9798a-e989-4a74-8b78-d2fe544fcca2")
# => name = "MyNode#60b9798a-e989-4a74-8b78-d2fe544fcca2"

# Edge case: if the name and the GUID is the same value, only one is kept.
var name = SxNetwork.generate_network_name("60b9798a-e989-4a74-8b78-d2fe544fcca2", "60b9798a-e989-4a74-8b78-d2fe544fcca2")
# => name = "60b9798a-e989-4a74-8b78-d2fe544fcca2"
  • static bool is_multiplayer_authority ( Node node, NodePath multiplayer_node_path )

    Check if a node is a multiplayer authority. If there is no network peer setup, it will not raise an error, it will return true.

Example
func _ready() -> void:
    if SxNetwork.is_multiplayer_authority(self, NodePath("")):
        print("I have the control!")
  • static int get_multiplayer_authority ( Node node, NodePath multiplayer_node_path )

    Get the multiplayer authority ID for a target node. If there is no network peer setup, it will not raise an error, it will return 1 (for root).

Example
func _ready() -> void:
    var master_id := SxNetwork.get_multiplayer_authority(self, NodePath(""))
  • static bool is_server ( SceneTree tree, NodePath multiplayer_node_path )

    Check if the target tree is a server. If there is no network peer setup, it will not raise an error, it will return true.

Example
func _ready() -> void:
    var is_server := SxNetwork.is_server(get_tree(), NodePath(""))
  • static bool is_network_enabled ( SceneTree tree, NodePath multiplayer_node_path )

    Check if the target tree has a network peer enabled.

Example
func _ready() -> void:
    var is_network_peer_on := SxNetwork.is_network_enabled(get_tree(), NodePath(""))
  • static String uuid4 ()

    Generate a UUID4 string.

Example
var uuid = SxNetwork.uuid4()
# => uuid = "60b9798a-e989-4a74-8b78-d2fe544fcca2"

SxNode

Inherits: Reference

Node helpers.

Description

Generic node helpers.

Methods

String

static print_tree_to_string ( Node node )

String

static print_tree_pretty_to_string ( Node node )

Method Descriptions

  • static String print_tree_to_string ( Node node )

    Returns the hierarchy tree from a specific node as a string.

Example
var my_node := $MyNode as Node
var tree := SxNode.print_tree_to_string(my_node)
  • static String print_tree_pretty_to_string ( Node node )

    Returns the "pretty" hierarchy tree from a specific node as a string.

Example
var my_node := $MyNode as Node
var tree := SxNode.print_tree_pretty_to_string(my_node)

SxNodeTracer

Inherits: Node

A tracing node, useful to display debug values.

Description

A tracing node, useful to display debug values.

It is shown through the SxDebugTools, in the "Node tracer" section.

To add a node tracer, just instance a SxNodeTracer in your scene, and use the trace_parameter function to register a parameter with a value (you will need to call it at each value update).

Example
extends Node

# Suppose your node have a SxNodeTracer as a child
onready var _tracer := $SxNodeTracer as SxNodeTracer

func _ready():
    # Let's display... the child count?
    _tracer.trace_parameter("children", len(get_children())

func _process(delta: float) -> void:
    # And show the node position, updated at each _process call
    _tracer.trace_parameter("position", position)

Properties

String

title

None

Methods

void

trace_parameter ( String name, Variant value )

Property Descriptions

  • String title

    A custom node title, if set.
    If not set, uses the parent node name.

Method Descriptions

  • void trace_parameter ( String name, Variant value )

    Create or update a parameter trace, to display through the SxDebugTools node tracer panel.

    If you need to continuously update a value, call trace_parameter in your node _process method.


SxOs

Inherits: Reference

OS methods.

Description

Generic OS methods.

Methods

void

static set_window_size_str ( String window_size )

bool

static is_mobile ()

bool

static is_web ()

Array

static list_files_in_directory ( String path, Array filters )

Method Descriptions

  • static void set_window_size_str ( String window_size )

    Set the current window size from a "WIDTHxHEIGHT" string.

Example
SxOs.set_window_size_str("1280x720")
  • static bool is_mobile ()

    Detect if the current system is a mobile environment.

Example
if SxOs.is_mobile():
    print("I'm on a mobile!")
  • static bool is_web ()

    Detect if the current system is a Web environment.

Example
if SxOs.is_web():
    print("I'm on a browser!")
  • static Array list_files_in_directory ( String path, Array filters )

    List all files in a directory.
    The filters argument is used to ignore some patterns.

    It returns an array of SxOs.DirOrFile.

Example
var files_and_dirs = SxOs.list_files_in_directory("user://my_folder", []):

SxOs.DirOrFile

Inherits: Reference

Description

Represents a path: a directory or a file.

Enumerations

enum SxOs.DirOrFile.Type:

  • DIRECTORY = 0 --- Path is a directory.

  • FILE = 1 --- Path is a file.

Methods

bool

is_file ()

bool

is_directory ()

Method Descriptions

  • bool is_file ()

    Check if the path is a file.

  • bool is_directory ()

    Check if the path is a file.


SxRand

Inherits: Reference

Rand methods.

Description

Generic rand methods.

Methods

int

static range_i ( int from, int to )

Vector2

static range_vec2 ( Vector2 from, Vector2 to )

Vector2

static unit_vec2 ()

bool

static chance_bool ( int chance )

Variant

static choice_array ( Array array )

Method Descriptions

  • static int range_i ( int from, int to )

    Generate a random integer between two values.

Example
var n := SxRand.range_i(1, 2)
  • static Vector2 range_vec2 ( Vector2 from, Vector2 to )

    Generate a random Vector2 between two values for each component.

Example
var n := SxRand.range_vec2(Vector2.ZERO, Vector2.ONE)
  • static Vector2 unit_vec2 ()

    Generate a random unit Vector2.

Example
var n := SxRand.unit_vec2()
  • static bool chance_bool ( int chance )

    Generate a random boolean following a chance percentage (between 0 and 100).

Example
# 75% chance!
var n := SxRand.chance_bool(75)
  • static Variant choice_array ( Array array )

    Choose a random value from a non-empty array.

Example
var v := SxRand.choice_array([1, 2, 3])

SxRpcService

Inherits: Node

Main RPC interface.

Description

Main RPC interface.

Methods

SxRpcService

static get_from_tree ( SceneTree tree )

Property Descriptions

  • SxClientRpc client

    Access to the client RPC interface.

  • SxServerRpc server

    Access to the server RPC interface.

  • SxSyncInput sync_input

    Access to the synchronized input interface.

Method Descriptions

  • static SxRpcService get_from_tree ( SceneTree tree )

    Return the main RPC service for a target SceneTree.


SxSceneRunner

Inherits: Control

Scene runner.

Description

Simple scene runner, can be used as a test suite.
Inherit the scene, define a scene_folder, then you can navigate scenes.

SxSceneRunner

Signals

  • scene_loaded ( String name )

    A scene has been loaded.

  • go_back ()

    A "go-back" navigation request has been made.

Properties

bool

show_back_button

None

String

scene_folder

None

Property Descriptions

  • bool show_back_button

    Show the back button.

  • String scene_folder

    Folder to scan, containing scenes.


SxSceneTransitioner

Inherits: CanvasLayer

A simple scene transition node, with a fade-in/fade-out effect.

Description

A simple scene transition node, with a fade-in/fade-out effect.

SxSceneTransitioner

Signals

  • animation_finished ()

    On animation finished.

Methods

void

fade_to_scene ( PackedScene scene, float speed = 1.0 )

void

fade_to_scene_path ( String scene_path, float speed = 1.0 )

void

fade_to_cached_scene ( SxLoadCache cache, String scene_name, float speed = 1.0 )

void

fade_in ( float speed = 1.0 )

void

fade_out ( float speed = 1.0 )

Method Descriptions

  • void fade_to_scene ( PackedScene scene, float speed = 1.0 )

    Fade the current scene to another already-loaded scene.

Example
# Suppose the node is autoloaded as GameSceneTransitioner.

GameSceneTransitioner.fade_to_scene(my_scene)
  • void fade_to_scene_path ( String scene_path, float speed = 1.0 )

    Fade the current scene to another scene, which will be loaded.

Example
# Suppose the node is autoloaded as GameSceneTransitioner.

GameSceneTransitioner.fade_to_scene_path("res://my_scene.tscn")
Example
# Suppose the node is autoloaded as GameSceneTransitioner.
# Suppose an SxLoadCache is autoloaded as GameSceneCache.

GameSceneTransitioner.fade_to_cached_scene(GameSceneCache, "MyScene")
  • void fade_in ( float speed = 1.0 )

    Apply a "fade in" effect.

Example
# Suppose the node is autoloaded as GameSceneTransitioner.

GameSceneTransitioner.fade_in()
  • void fade_out ( float speed = 1.0 )

    Apply a "fade out" effect.

Example
# Suppose the node is autoloaded as GameSceneTransitioner.

GameSceneTransitioner.fade_out()

SxServerPeer

Inherits: Node

Configurable network peer, server side.

Description

Configurable network peer, server side.

Signals

  • peer_connected ( int peer_id )

    On a distant peer connection.

  • peer_disconnected ( int peer_id )

    On a distant peer disconnection.

  • players_updated ( Dictionary players )

    On players data update (for example a username change).

Methods

Dictionary

get_players ()

Node

spawn_synchronized_scene ( NodePath parent, String scene_path, int owner_peer_id = 1, Dictionary master_configuration = {} )

Node

spawn_synchronized_named_scene ( NodePath parent, String scene_path, String scene_name, int owner_peer_id = 1, Dictionary master_configuration = {} )

Node

spawn_synchronized_scene_mapped ( NodePath parent, String name, String server_scene_path, String client_scene_path, int owner_peer_id = 1, Dictionary master_configuration = {} )

void

remove_synchronized_node ( Node node )

bool

is_quitting ()

bool

set_quit_status ()

Property Descriptions

  • int server_port

    Server port.

  • int max_players

    Max players allowed to join.

  • bool use_websockets

    Use a WebSockets server (instead of ENet).

Method Descriptions

  • Dictionary get_players ()

    Get known players data.

  • Node spawn_synchronized_scene ( NodePath parent, String scene_path, int owner_peer_id = 1, Dictionary master_configuration = {} )

    Spawn a synchronized scene on the server, with replicas sent to connected clients.

  • Node spawn_synchronized_named_scene ( NodePath parent, String scene_path, String scene_name, int owner_peer_id = 1, Dictionary master_configuration = {} )

    Same thing than spawn_synchronized_scene, but with a specific node name.

  • Node spawn_synchronized_scene_mapped ( NodePath parent, String name, String server_scene_path, String client_scene_path, int owner_peer_id = 1, Dictionary master_configuration = {} )

    Spawn a synchronized named scene on the server using a specific scene path for the server and a different path for the client.

    This method is useful if you want to mimic the server nodes on the client with different scene paths.

  • void remove_synchronized_node ( Node node )

    Remove a node from the server and the connected clients.

  • bool is_quitting ()

    Check if the server is in the shutdown procedure.
    It can be useful to cleanup stuff before the server quits.

  • bool set_quit_status ()

    Change the "quit" status of the server.

SxServerPeer.SxSynchronizedScenePath

Inherits: Reference

Description

A synchronized scene path: wrapper around a scene creation for network dispatch.

Property Descriptions

  • String scene_path

    Scene path.

  • int owner_peer_id

    Peer ID of the node owner.

  • Dictionary master_configuration

    Master configuration, contains owner info for child nodes.


SxServerRpc

Inherits: Node

Server RPC interface.

Description

Server RPC interface.

Signals

  • player_username_updated ( int player_id, String username )

    On a player username update.

Methods

void

ping ()

void

send_input ( Dictionary input )

void

update_player_username ( String username )

Method Descriptions

  • void ping ()

    Send a "ping" event to the server.

  • void send_input ( Dictionary input )

    Send player input to the server.

  • void update_player_username ( String username )

    Send new username to the server.


SxShader

Inherits: Reference

Shader methods.

Description

Generic shader methods.

Methods

Variant

static get_shader_parameter ( CanvasItem item, String name )

void

static set_shader_parameter ( CanvasItem item, String name, Variant value )

Method Descriptions

  • static Variant get_shader_parameter ( CanvasItem item, String name )

    Get a shader param from a canvas item.

    Handles edge cases like missing material or non-shader material.

Example
var param := SxShader.get_shader_param($MyNode, "ratio") as float
  • static void set_shader_parameter ( CanvasItem item, String name, Variant value )

    Set a shader param on a canvas item.

    Handles edge cases like missing material or non-shader material.

Example
SxShader.set_shader_param($MyNode, "ratio", 0.25)

SxSyncBarrier

Inherits: Node

Simple network barrier.

Description

Simple network barrier.

Enumerations

enum SxSyncBarrier.BarrierJoinStatus:

  • NOT_READY = 0 --- Barrier is waiting for clients.

  • OK = 1 --- Barrier is ready, all clients are ready.

  • TIMEOUT = 2 --- Barrier have timed out.

Constants

  • DEFAULT_TIMEOUT = 60 --- Default barrier timeout value.

Methods

void

set_server_peer ( SxServerPeer peer )

void

await_peers ()

Method Descriptions

  • void set_server_peer ( SxServerPeer peer )

    Set the server peer for the barrier (mandatory before using it).

  • void await_peers ()

    Wait for each peers to connect, or wait for the timeout.

    This method will remove the barrier on completion/timeout.


SxSyncInput

Inherits: Node

Synchronized input interface.

Description

Synchronized input interface.

Methods

SxSyncPeerInput

get_current_input ()

void

create_peer_input ( int peer_id )

void

remove_peer_input ( int peer_id )

void

update_peer_input_from_json ( int peer_id, Dictionary input )

bool

is_action_pressed ( Node source, String action_name )

bool

is_action_just_pressed ( Node source, String action_name )

float

get_action_strength ( Node source, String action_name )

Method Descriptions

  • void create_peer_input ( int peer_id )

    Create a peer input for a specific peer ID.

  • void remove_peer_input ( int peer_id )

    Remove a peer input for a specific peer ID.

  • void update_peer_input_from_json ( int peer_id, Dictionary input )

    Update peer input state from a JSON dict.

  • bool is_action_pressed ( Node source, String action_name )

    Check if an action is pressed for a specific node (will check its owner sync input).

  • bool is_action_just_pressed ( Node source, String action_name )

    Check if an action is "just pressed" for a specific node (will check its owner sync input).

  • float get_action_strength ( Node source, String action_name )

    Get an action strength for a specific node (will check its owner sync input).


SxSyncPeerInput

Inherits: Node

Synchronized input interface for a specific peer.

Description

Synchronized input interface for a specific peer.

Methods

Dictionary

to_json ()

void

update_from_json ( Dictionary input )

bool

is_action_pressed ( String action_name )

bool

is_action_just_pressed ( String action_name )

float

get_action_strength ( String action_name )

void

query_input ()

Method Descriptions

  • Dictionary to_json ()

    Convert each input state to JSON.

  • void update_from_json ( Dictionary input )

    Update each input state from JSON data.

  • bool is_action_pressed ( String action_name )

    Check if an action is pressed.

  • bool is_action_just_pressed ( String action_name )

    Check if an action is "just pressed".

  • float get_action_strength ( String action_name )

    Get an action strength.

  • void query_input ()

    Update the sync input from local input state.

SxSyncPeerInput.InputState

Inherits: Object

Description

No description.

Properties

bool

pressed

None

bool

just_pressed

None

float

strength

None

Property Descriptions

  • bool pressed

    "Pressed" status for an input.

  • bool just_pressed

    "Just pressed" status for an input.

  • float strength

    Strength for an input.

Method Descriptions

  • Dictionary to_json ()

    Convert an input state to JSON.

  • void update_from_json ( Dictionary d )

    Update an input state from JSON data.


SxText

Inherits: Reference

Text methods.

Description

Generic text methods.

Methods

String

static to_camel_case ( String s )

String

static to_pascal_case ( String s )

Method Descriptions

  • static String to_camel_case ( String s )

    Convert a text to camel case.

Example
var text := SxText.to_camel_case("hello_world")
# => text = "helloWorld"
  • static String to_pascal_case ( String s )

    Convert a text to Pascal case.

Example
var text := SxText.to_pascal_case("hello_world")
# => text = "HelloWorld"

SxTileMap

Inherits: Reference

Tilemap methods.

Description

Generic tilemap methods.

Method Descriptions

  • static float get_cell_rotation ( TileMap tilemap, Vector2 pos )

    Get a specific cell rotation, in radians.

Example
var r := SxTileMap.get_cell_rotation(tilemap, Vector2(0, 0))
Example
var params := SxTileMap.get_cell_rotation_params(tilemap, Vector2(0, 0))
Example
var params := SxTileMap.get_cell_rotation_params(tilemap, Vector2(0, 0))
var angle := SxTileMap.rotation_params_to_angle(params)
Example
var params := SxTileMap.rotation_degrees_to_params(90)
Example
var tile_data := SxTileMap.create_dump(tilemap)
  • static void apply_dump ( TileMap tilemap, PoolIntArray array )

    Overwrite tilemap contents with a dump.

    Before applying the dump, it will clear all the tilemap contents.

Example
SxTileMap.apply_dump(tilemap, my_dump)

SxTileMap.CellRotationParams

Inherits: Node

Description

Helper class representing transpose/flip parameters for a TileMap cell.

Properties

bool

transpose

None

bool

flip_x

None

bool

flip_y

None

Methods

SxTileMap.CellRotationParams

static from_values ( bool transpose, bool flip_x, bool flip_y )

Property Descriptions

  • bool transpose

    Is the cell transposed?

  • bool flip_x

    Is the cell flipped on axis X?

  • bool flip_y

    Is the cell flipped on axis Y?

Method Descriptions


SxUi

Inherits: Reference

UI methods.

Description

Generic UI methods.

Methods

void

static set_full_rect_no_mouse ( Control node )

void

static set_margin_container_margins ( MarginContainer node, float value )

Method Descriptions

  • static void set_full_rect_no_mouse ( Control node )

    Apply a "Wide" anchors and margin preset to a Control node, with an "Ignore" mouse filter.

  • static void set_margin_container_margins ( MarginContainer node, float value )

    Apply an uniform margin on all sides for a MarginContainer.


SxVirtualButton

Inherits: TextureRect

Virtual button to be included in a SxVirtualControls.

Description

Virtual button to be included in a SxVirtualControls.

Signals

  • touched ()

    The button was touched.

  • released ()

    The button was released.

Properties

String

action_button

None

Property Descriptions

  • String action_button

    Action button to press on input.


SxVirtualControls

Inherits: Control

A simple virtual controls module.

Description

A simple virtual controls module.

You only need to create a new scene, inheriting from SxVirtualControls, and then instancing your controls in it (adding SxVirtualButtons and SxVirtualJoysticks).

On buttons, you can affect an action key (mapped in the Input Map), and on joysticks, you can affect 4 actions keys, one for each direction.

You have 3 samples at your disposal in the plugin.

SxVirtualControls

Enumerations

enum SxVirtualControls.DisplayMode:

  • OnlyMobile = 0 --- Only display the controls on a mobile environment.

  • Always = 1 --- Always display the controls, in desktop or mobile.

Property Descriptions


SxVirtualJoystick

Inherits: TextureRect

Virtual joystick to be included in a SxVirtualControls.

Description

Virtual joystick to be included in a SxVirtualControls.

Signals

  • changed ( Vector2 movement )

    The joystick value has changed.

  • touched ()

    The button was touched.

  • released ()

    The button was released.

Property Descriptions

  • String action_axis_left

    Action to press on axis left.

  • String action_axis_right

    Action to press on axis right.

  • String action_axis_up

    Action to press on axis up.

  • String action_axis_down

    Action to press on axis down.

  • float dead_zone

    Dead zone.