Moai SDK  2.0
MOAISim Class Reference
+ Inheritance diagram for MOAISim:

Function List

clearLoopFlags
 
crash
 
enterFullscreenMode
 
exitFullscreenMode
 
framesToTime
 
getActionMgr
 
getDeviceTime
 
getElapsedTime
 
getLoopFlags
 
getLuaObjectCount
 
getMemoryUsage
 
getMemoryUsagePlain
 
getPerformance
 
getStep
 
getStepCount
 
hideCursor
 
openWindow
 
pauseTimer
 
setBoostThreshold
 
setCpuBudget
 
setGCActive
 
setGCStep
 
setLongDelayThreshold
 
setLoopFlags
 
setLuaAllocLogEnabled
 
setStep
 
setStepMultiplier
 
setStepSmoothing
 
setTimerError
 
setTraceback
 
setTextInputRect
 
showCursor
 
timeToFrames
 
clearRenderStack
 
popRenderPass
 
pushRenderPass
 
removeRenderPass
 

Additional Inherited Members

- Function List inherited from MOAIGlobalEventSource
template<typename TYPE >
getListener
 
template<typename TYPE >
setListener
 

Detailed Description

ConstantsDescription
MOAISim.EVENT_FINALIZE
MOAISim.EVENT_PAUSE
MOAISim.EVENT_RESUME
MOAISim.SIM_LOOP_FORCE_STEP
MOAISim.SIM_LOOP_ALLOW_BOOST
MOAISim.SIM_LOOP_ALLOW_SPIN
MOAISim.SIM_LOOP_NO_DEFICIT
MOAISim.SIM_LOOP_NO_SURPLUS
MOAISim.SIM_LOOP_RESET_CLOCK
MOAISim.SIM_LOOP_ALLOW_SOAK
MOAISim.LOOP_FLAGS_DEFAULT
MOAISim.LOOP_FLAGS_FIXED
MOAISim.LOOP_FLAGS_MULTISTEP
MOAISim.DEFAULT_STEPS_PER_SECOND Value is 60
MOAISim.DEFAULT_BOOST_THRESHOLD Value is 3
MOAISim.DEFAULT_LONG_DELAY_THRESHOLD Value is 10
MOAISim.DEFAULT_CPU_BUDGET Value is 2
MOAISim.DEFAULT_STEP_MULTIPLIER Value is 1

Function Documentation

clearLoopFlags

Uses the mask provided to clear the loop flags.


function clearLoopFlags ( [ number mask ] )

Parameters
numbermask Optional. Default value is 0xffffffff.
Returns
nil
clearRenderStack

Alias for MOAIRenderMgr.clearRenderStack (). THIS METHOD IS DEPRECATED AND WILL BE REMOVED IN A FUTURE RELEASE.


function clearRenderStack ()

Returns
nil
crash

Crashes Moai with a null pointer dereference.


function crash ()

Returns
nil
enterFullscreenMode

Enters fullscreen mode on the device if possible.


function enterFullscreenMode ()

Returns
nil
exitFullscreenMode

Exits fullscreen mode on the device if possible.


function exitFullscreenMode ()

Returns
nil
framesToTime

Converts the number of frames to time passed in seconds.


function framesToTime ( number frames )

Parameters
numberframes The number of frames.
Returns
number time
getActionMgr

Get the sim's action tree. This is the 'global' action tree that all newly started actions are automatically added.


function getActionMgr ()

Returns
MOAIActionTree actionMgr
getDeviceTime

Gets the raw device clock. This is a replacement for Lua's os.time ().


function getDeviceTime ()

Returns
number time
getElapsedTime

Gets the number of seconds elapsed since the application was started.


function getElapsedTime ()

Returns
number time
getLoopFlags

Returns the current loop flags.


function getLoopFlags ()

Returns
number mask
getLuaObjectCount

Gets the total number of objects in memory that inherit MOAILuaObject. Count includes objects that are not bound to the Lua runtime.


function getLuaObjectCount ()

Returns
number count
getMemoryUsage

Get the current amount of memory used by MOAI and its subsystems. This will attempt to return reasonable estimates where exact values cannot be obtained. Some fields represent informational fields (i.e. are not double counted in the total, but present to assist debugging) and may be only available on certain platforms (e.g. Windows, etc). These fields begin with a '_' character.


function getMemoryUsage ()

Returns
table usage
getMemoryUsagePlain

Returns lua and texture memory usage measured by MOAI subsystems. This function tries to avoid allocations to minimize skewing the results. Suitable for realtime memory monitoring.


function getMemoryUsagePlain ()

Returns
number lua, number texture
getPerformance

Returns an estimated frames per second and other performance counters based on measurements taken at every render.


function getPerformance ()

Returns
number fps, number seconds, number seconds, number seconds, number seconds
getStep

Gets the amount of time (in seconds) that it takes for one frame to pass.


function getStep ()

Returns
number size
getStepCount

Gets the number of times the sim was stepped since the application was started.


function getStepCount ()

Returns
number steps
hideCursor

Hides system cursor.


function hideCursor ()

Returns
nil
openWindow

Opens a new window for the application to render on. This must be called before any rendering can be done, and it must only be called once.


function openWindow ( string title, number width, number height )

Parameters
stringtitle The title of the window.
numberwidth The width of the window in pixels.
numberheight The height of the window in pixels.
Returns
nil
pauseTimer

Pauses or unpauses the device timer, preventing any visual updates (rendering) while paused.


function pauseTimer ( boolean pause )

Parameters
booleanpause Whether the device timer should be paused.
Returns
nil
popRenderPass

Alias for MOAIRenderMgr.popRenderPass (). THIS METHOD IS DEPRECATED AND WILL BE REMOVED IN A FUTURE RELEASE.


function popRenderPass ()

Returns
nil
pushRenderPass

Alias for MOAIRenderMgr.pushRenderPass (). THIS METHOD IS DEPRECATED AND WILL BE REMOVED IN A FUTURE RELEASE.


function pushRenderPass ( MOAIDrawable renderable )

Parameters
MOAIDrawablerenderable
Returns
nil
removeRenderPass

Alias for MOAIRenderMgr.removeRenderPass (). THIS METHOD IS DEPRECATED AND WILL BE REMOVED IN A FUTURE RELEASE.


function removeRenderPass ( MOAIDrawable renderable )

Parameters
MOAIDrawablerenderable
Returns
nil
setBoostThreshold

Sets the boost threshold, a scalar applied to step. If the gap between simulation time and device time is greater than the step size multiplied by the boost threshold and MOAISim.SIM_LOOP_ALLOW_BOOST is set in the loop flags, then the simulation is updated once with a large, variable step to make up the entire gap.


function setBoostThreshold ( [ number boostThreshold ] )

Parameters
numberboostThreshold Optional. Default value is DEFAULT_BOOST_THRESHOLD.
Returns
nil
setCpuBudget

Sets the amount of time (given in simulation steps) to allow for updating the simulation.


function setCpuBudget ( number budget )

Parameters
numberbudget Default value is DEFAULT_CPU_BUDGET.
Returns
nil
setGCActive

Enable incremental garbage collection.


function setGCActive ( boolean active )

Parameters
booleanactive Default value is false.
Returns
nil
setGCStep

Sets a step to use when running the incremental gc each frame.


function setGCStep ( number step )

Parameters
numberstep
Returns
nil
setLongDelayThreshold

Sets the long delay threshold. If the simulation step falls behind the given threshold, the deficit will be dropped: the simulation will neither spin nor boost to catch up.


function setLongDelayThreshold ( [ number longDelayThreshold ] )

Parameters
numberlongDelayThreshold Optional. Default value is DEFAULT_LONG_DELAY_THRESHOLD.
Returns
nil
setLoopFlags

Fine tune behavior of the simulation loop. MOAISim.SIM_LOOP_ALLOW_SPIN will allow the simulation step to run multiple times per update to try and catch up with device time, but will abort if processing the simulation exceeds the configured step time. MOAISim.SIM_LOOP_ALLOW_BOOST will permit a variable update step if simulation time falls too far behind device time (based on the boost threshold). Be warned: this can wreak havoc with physics and stepwise animation or game AI. Three presets are provided: MOAISim.LOOP_FLAGS_DEFAULT, MOAISim.LOOP_FLAGS_FIXED, and MOAISim.LOOP_FLAGS_MULTISTEP.


function setLoopFlags ( [ number flags ] )

Parameters
numberflags Optional. Mask or a combination of MOAISim.SIM_LOOP_FORCE_STEP, MOAISim.SIM_LOOP_ALLOW_BOOST, MOAISim.SIM_LOOP_ALLOW_SPIN, MOAISim.SIM_LOOP_NO_DEFICIT, MOAISim.SIM_LOOP_NO_SURPLUS, MOAISim.SIM_LOOP_RESET_CLOCK. Default value is 0.
Returns
nil
setLuaAllocLogEnabled

Toggles log messages from Lua allocator.


function setLuaAllocLogEnabled ( [ boolean enable ] )

Parameters
booleanenable Optional. Default value is 'false.'
Returns
nil
setStep

Sets the size of each simulation step (in seconds).


function setStep ( number step )

Parameters
numberstep The step size. Default value is 1 / DEFAULT_STEPS_PER_SECOND.
Returns
nil
setStepMultiplier

Runs the simulation multiple times per step (but with a fixed step size). This is used to speed up the simulation without providing a larger step size (which could destabilize physics simulation).


function setStepMultiplier ( number count )

Parameters
numbercount Default value is DEFAULT_STEP_MULTIPLIER.
Returns
nil
setStepSmoothing

Average delta time over N last frames. This is useful to filter out momentary single-frame spikes. Can make difference even in fixed step setup (helps to avoids double steps).


function setStepSmoothing ( number count )

Parameters
numbercount Number of frames. Default is 0 (no smoothing).
Returns
nil
setTextInputRect

Sets text input rect.


function setTextInputRect ()

Returns
nil
setTimerError

Sets the tolerance for timer error. This is a multiplier of step. Timer error tolerance is step * timerError.


function setTimerError ( number timerError )

Parameters
numbertimerError Default value is 0.0.
Returns
nil
setTraceback

Sets the function to call when a traceback occurs in Lua.


function setTraceback ( function callback )

Parameters
functioncallback Function to execute when the traceback occurs
Returns
nil
showCursor

Shows system cursor.


function showCursor ()

Returns
nil
timeToFrames

Converts the number of time passed in seconds to frames.


function timeToFrames ( number time )

Parameters
numbertime The number of seconds.
Returns
number frames