Module ncine

The entry point for the Lua API of the nCine.

Don’t forget to call start if needed.

Functions

on_pre_init (cfg) A callback that is called once, before the nCine is initialized.
on_init () A callback that is called once, after the nCine has been initialized.
on_frame_start () A callback that is called every time a new frame starts
on_post_update () A callback that is called every time the scenegraph has been traversed and all nodes have been transformed
on_draw_viewport (viewport) A callback that is called every time a viewport is going to be drawn
on_frame_end () A callback that is called at the end of each frame, just before swapping drawing buffers
on_resize_window (width, height) A callback that is called every time the window is resized (by the system or the user)
on_change_scaling_factor (factor) A callback that is called every time the window scaling factor changes
on_shutdown () A callback that is called once, before the nCine shuts down
on_suspend () A callback that is called every time the application needs to be suspended
on_resume () A callback that is called every time the application resumes from suspension
start () Starts the application game loop

This function should be called after defining the required callback functions, and only if launching the script from the stand-alone lua interpreter.

Tables

ncine A table of useful run-time constants

input_event_handler Functions

on_key_pressed (event) Callback function called every time a key is pressed
on_key_released (event) Callback function called every time a key is released
on_text_input (event) Callback function called every time a text input is generated
on_touch_down (event) Callback function called every time the first screen touch is made
on_touch_up (event) Callback function called every time the last screen touch is released
on_touch_move (event) Callback function called every time a screen touch is moved
on_pointer_down (event) Callback function called every time a screen touch different than the first one is made
on_pointer_up (event) Callback function called every time a screen touch different than the last one is released
on_acceleration (event) Callback function called at fixed time with the updated reading from the accelerometer sensor
on_mouse_button_pressed (event) Callback function called every time a mouse button is pressed
on_mouse_button_released (event) Callback function called every time a mouse button is released
on_mouse_moved (event) Callback function called every time the mouse is moved
on_scroll_input (event) Callback function called every time a scroll input occurs (mouse wheel, touchpad gesture, etc.)
on_joy_button_pressed (event) Callback function called every time a joystick button is pressed
on_joy_button_released (event) Callback function called every time a joystick button is released
on_joy_hat_moved (event) Callback function called every time a joystick hat is moved
on_joy_axis_moved (event) Callback function called every time a joystick axis is moved
on_joymapped_button_pressed (event) Callback function called every time a button of a joystick with mapping is pressed
on_joymapped_button_released (event) Callback function called every time a button of a joystick with mapping is released
on_joymapped_axis_moved (event) Callback function called every time an axis of a joystick with mapping is moved
on_joy_connected (event) Callback function called every time a joystick is connected
on_joy_disconnected (event) Callback function called every time a joystick is disconnected
on_quit_request () Callback function called when the system sends a quit event, for example when the user clicks the window close button.


Functions

on_pre_init (cfg)
A callback that is called once, before the nCine is initialized.

It can be used to change the initialization settings.

Parameters:

  • cfg ncine.app_configuration The configuration table
on_init ()
A callback that is called once, after the nCine has been initialized.

It can be used to construct the object required by the scene.

on_frame_start ()
A callback that is called every time a new frame starts
on_post_update ()
A callback that is called every time the scenegraph has been traversed and all nodes have been transformed
on_draw_viewport (viewport)
A callback that is called every time a viewport is going to be drawn

Parameters:

  • viewport viewportObj The viewport currently being drawn
on_frame_end ()
A callback that is called at the end of each frame, just before swapping drawing buffers
on_resize_window (width, height)
A callback that is called every time the window is resized (by the system or the user)

Parameters:

  • width integer The new width of the window
  • height integer The new height of the window
on_change_scaling_factor (factor)
A callback that is called every time the window scaling factor changes

Parameters:

  • factor number The new scaling factor
on_shutdown ()
A callback that is called once, before the nCine shuts down It can be used to destroy objects constructed in ncine.on_init()
on_suspend ()
A callback that is called every time the application needs to be suspended
on_resume ()
A callback that is called every time the application resumes from suspension
start ()

Starts the application game loop

This function should be called after defining the required callback functions, and only if launching the script from the stand-alone lua interpreter.

For example:

if ncine == nil then
  local names = { "ncine", "ncine_d", "libncine", "libncine_d" }
  for i, name in ipairs(names) do
    local ok, mod = pcall(require, name)
    if ok then
      break
    end
  end
  needs_start = true
end

function nc.on_init()
  [...]
end

function nc.on_frame_start()
  [...]
end

if needs_start then
  nc.start()
end

Tables

ncine
A table of useful run-time constants

Fields:

  • _VERSION string The version string
  • _GITREVCOUNT string The git revision count
  • _GITSHORTHASH string The git short hash
  • _GITLATCOMMITDATE string The git last commit date
  • _GITBRANCH string The git branch
  • _GITTAG string The git tag
  • MINGW boolean True if running on MinGW
  • WINDOWS boolean True if running on Windows
  • MACOS boolean True if running on macOS
  • ANDROID boolean True if running on Android
  • EMSCRIPTEN boolean True if running on the web via Emscripten
  • LINUX boolean True if running on Linux
  • DEBUG boolean True if linked with a debug build of the nCine library

input_event_handler Functions

on_key_pressed (event)
Callback function called every time a key is pressed

Parameters:

  • event keyboard_event
on_key_released (event)
Callback function called every time a key is released

Parameters:

  • event keyboard_event
on_text_input (event)
Callback function called every time a text input is generated

Parameters:

  • event text_input_event
on_touch_down (event)
Callback function called every time the first screen touch is made

Parameters:

  • event touch_event
on_touch_up (event)
Callback function called every time the last screen touch is released

Parameters:

  • event touch_event
on_touch_move (event)
Callback function called every time a screen touch is moved

Parameters:

  • event touch_event
on_pointer_down (event)
Callback function called every time a screen touch different than the first one is made

Parameters:

  • event touch_event
on_pointer_up (event)
Callback function called every time a screen touch different than the last one is released

Parameters:

  • event touch_event
on_acceleration (event)
Callback function called at fixed time with the updated reading from the accelerometer sensor

Parameters:

  • event accelerometer_event
on_mouse_button_pressed (event)
Callback function called every time a mouse button is pressed

Parameters:

  • event mouse_event
on_mouse_button_released (event)
Callback function called every time a mouse button is released

Parameters:

  • event mouse_event
on_mouse_moved (event)
Callback function called every time the mouse is moved

Parameters:

  • event mouse_state
on_scroll_input (event)
Callback function called every time a scroll input occurs (mouse wheel, touchpad gesture, etc.)

Parameters:

  • event scroll_event
on_joy_button_pressed (event)
Callback function called every time a joystick button is pressed

Parameters:

  • event joy_button_event
on_joy_button_released (event)
Callback function called every time a joystick button is released

Parameters:

  • event joy_button_event
on_joy_hat_moved (event)
Callback function called every time a joystick hat is moved

Parameters:

  • event joy_hat_event
on_joy_axis_moved (event)
Callback function called every time a joystick axis is moved

Parameters:

  • event joy_axis_event
on_joymapped_button_pressed (event)
Callback function called every time a button of a joystick with mapping is pressed

Parameters:

  • event joymapped_button_event
on_joymapped_button_released (event)
Callback function called every time a button of a joystick with mapping is released

Parameters:

  • event joymapped_button_event
on_joymapped_axis_moved (event)
Callback function called every time an axis of a joystick with mapping is moved

Parameters:

  • event joymapped_axis_event
on_joy_connected (event)
Callback function called every time a joystick is connected

Parameters:

  • event joy_connection_event
on_joy_disconnected (event)
Callback function called every time a joystick is disconnected

Parameters:

  • event joy_connection_event
on_quit_request ()
Callback function called when the system sends a quit event, for example when the user clicks the window close button.

Returns true if the application should quit.

Returns:

    boolean
generated by LDoc 1.5.0 Last updated 2024-12-18 15:08:56