Game Development Reference
In-Depth Information
Creating a sandbox Lua script
With a basic sandbox application out of the way, we're going to create the basic Lua script
that sets up the sandbox. First, create a new Sandbox.lua script within the script folder:
Create the Lua file as follows:
src/my_sandbox/script/Sandbox.lua
A sandbox Lua script must implement four global functions that the C++ code will call,
and they are Sandbox_Cleanup , Sandbox_HandleEvent , Sand-
box_Initialize , and Sandbox_Update :
Sandbox.lua :
function Sandbox_Cleanup(sandbox)
end
function Sandbox_HandleEvent(sandbox, event)
end
function Sandbox_Initialize(sandbox)
end
function Sandbox_Update(sandbox, deltaTimeInMillis)
end
With the basic hooks in place, modify your SandboxApplication class to create a
sandbox based on your Lua script:
MySandbox.cpp :
void MySandbox::Initialize() {
SandboxApplication::Initialize();
...
CreateSandbox("Sandbox.lua");
}
Search WWH ::




Custom Search