GlyEngine 0.4
Create games and apps with lua
Loading...
Searching...
No Matches
Node

Functions

local function emit (application, key, a, b, c, d, e, f)
 send event to node
local function load (application)
 create new node
local function spawn (application, parent)
 register node to event bus @decorator
local function kill (application)
 unregister node from event bus @decorator
local function node_pause (application, key)
 disable node callback @decorator
local function node_resume (application, key)
 enable node callback @decorator

Detailed Description

Warning
This is an advanced API!
only for advanced programmers, You might be lost if you are a beginner.

Event Direct Message

  • Node 1
    std.node.emit(node_2, 'say', 'hello!')

Event Bus Registering

Parents
  • Root
    std.node.spawn(node_1)
    std.node.spawn(node_3)
  • Node 1
    std.node.spawn(node_2)
Custom Events
  • Node 3
    std.bus.emit('say', 'hello for everyone!')
Engine Events

Function Documentation

◆ emit()

local function emit ( application ,
key ,
a ,
b ,
c ,
d ,
e ,
f  )
Todo
remove emit from std.node in 0.4.X
Tip
You can send message to "not spawned" node, as if he were an orphan.
Alternatives
  • std.node.emit_root send event to first node.
  • std.node.emit_parent send event to the node that registered current.

◆ kill()

local function kill ( application )
Example
if std.milis > minigame_limit_time then
std.node.kill(minigame)
end

◆ load()

local function load ( application )
Note
When build the main game file, it will be directly affected by the build.
Parameters
[in]application
Returns
node
Example
local game = std.node.load('samples/awesome/game.lua')
print(game.meta.title)
local function print(pos_x, pos_y, text)
std.text.print

◆ node_pause()

local function node_pause ( application ,
key  )

stop receive specific event int the application

Example
if not paused and std.key.press.menu then
std.node.pause(minigame, 'loop')
end

◆ node_resume()

local function node_resume ( application ,
key  )

return to receiving specific event in the application

Example
if paused and std.key.press.menu then
std.node.resume(minigame, 'loop')
end

◆ spawn()

local function spawn ( application ,
parent  )
Parameters
[in/out]application
Example
local game = std.node.load('samples/awesome/game.lua')
std.node.spawn(game)