Moai SDK  1.5 revision 1 (MoaiEdition)
MOAISim Class Reference

Inherits MOAIGlobalClass< TYPE, SUPER >.

List of all members.

Function List

  clearLoopFlags
  crash
  enterFullscreenMode
  exitFullscreenMode
  showCursor
  hideCursor
  forceGC
  framesToTime
  getDeviceTime
  getElapsedFrames
  getElapsedTime
  getHistogram
  getLoopFlags
  getLuaObjectCount
  getMemoryUsage
  getPerformance
  getStep
  openWindow
  pauseTimer
  reportHistogram
  reportLeaks
  setBoostThreshold
  setCpuBudget
  setHistogramEnabled
  setLeakTrackingEnabled
  setLongDelayThreshold
  setLoopFlags
  setLuaAllocLogEnabled
  setStep
  setStepMultiplier
  setTimerError
  setTraceback
  timeToFrames
  clearRenderStack
  popRenderPass
  pushRenderPass
  removeRenderPass

Function Documentation

Uses the mask provided to clear the loop flags.


function clearLoopFlags ( [ number mask ] )
Parameters:
mask ( number ) Optional. Default value is 0xffffffff.
Returns:
nil

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


function clearRenderStack ()
Returns:
nil

Crashes Moai with a null pointer dereference.


function crash ()
Returns:
nil

Enters fullscreen mode on the device if possible.


function enterFullscreenMode ()
Returns:
nil

Exits fullscreen mode on the device if possible.


function exitFullscreenMode ()
Returns:
nil

Runs the garbage collector repeatedly until no more MOAIObjects can be collected.


function forceGC ()
Returns:
nil

Converts the number of frames to time passed in seconds.


function framesToTime ( number frames )
Parameters:
frames ( number ) The number of frames.
Returns:
time ( number )

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


function getDeviceTime ()
Returns:
time ( number )

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


function getElapsedFrames ()
Returns:
frames ( number )

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


function getElapsedTime ()
Returns:
time ( number )

Generates a histogram of active MOAIObjects and returns it in a table containing object tallies indexed by object class names.


function getHistogram ()
Returns:
histogram ( table )

Returns the current loop flags.


function getLoopFlags ()
Returns:
mask ( number )

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:
count ( number )

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:
usage ( table )

Returns an estimated frames per second based on measurements taken at every render.


function getPerformance ()
Returns:
fps ( number )

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


function getStep ()
Returns:
size ( number )

Hides system cursor.


function hideCursor ()
Returns:
nil

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:
title ( string ) The title of the window.
width ( number ) The width of the window in pixels.
height ( number ) The height of the window in pixels.
Returns:
nil

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


function pauseTimer ( boolean pause )
Parameters:
pause ( boolean ) Whether the device timer should be paused.
Returns:
nil

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


function popRenderPass ()
Returns:
nil

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


function pushRenderPass ( MOAIRenderable renderable )
Parameters:
renderable ( MOAIRenderable )
Returns:
nil

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


function removeRenderPass ( MOAIRenderable renderable )
Parameters:
renderable ( MOAIRenderable )
Returns:
nil

Generates a histogram of active MOAIObjects.


function reportHistogram ()
Returns:
nil

Analyze the currently allocated MOAI objects and create a textual report of where they were declared, and what Lua references (if any) can be found. NOTE: This is incredibly slow, so only use to debug leaking memory issues. This will also trigger a full garbage collection before performing the required report. (Equivalent of collectgarbage("collect").)


function reportLeaks ( boolean clearAfter )
Parameters:
clearAfter ( boolean ) If true, it will reset the allocation tables (without freeing the underlying objects). This allows this method to be called after a known operation and get only those allocations created since the last call to this function.
Returns:
nil

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:
boostThreshold ( number ) Optional. Default value is DEFAULT_BOOST_THRESHOLD.
Returns:
nil

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


function setCpuBudget ( number budget )
Parameters:
budget ( number ) Default value is DEFAULT_CPU_BUDGET.
Returns:
nil

Enable tracking of every MOAILuaObject so that an object count histogram may be generated.


function setHistogramEnabled ( [ boolean enable ] )
Parameters:
enable ( boolean ) Optional. Default value is false.
Returns:
nil

Enable extra memory book-keeping measures that allow all MOAI objects to be tracked back to their point of allocation (in Lua). Use together with MOAISim.reportLeaks() to determine exactly where your memory usage is being created. NOTE: This is very expensive in terms of both CPU and the extra memory associated with the stack info book-keeping. Use only when tracking down leaks.


function setLeakTrackingEnabled ( [ boolean enable ] )
Parameters:
enable ( boolean ) Optional. Default value is false.
Returns:
nil

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:
longDelayThreshold ( number ) Optional. Default value is DEFAULT_LONG_DELAY_THRESHOLD.
Returns:
nil

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:
flags ( number ) 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

Toggles log messages from Lua allocator.


function setLuaAllocLogEnabled ( [ boolean enable ] )
Parameters:
enable ( boolean ) Optional. Default value is 'false.'
Returns:
nil

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


function setStep ( number step )
Parameters:
step ( number ) The step size. Default value is 1 / DEFAULT_STEPS_PER_SECOND.
Returns:
nil

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:
count ( number ) Default value is DEFAULT_STEP_MULTIPLIER.
Returns:
nil

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


function setTimerError ( number timerError )
Parameters:
timerError ( number ) Default value is 0.0.
Returns:
nil

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


function setTraceback ( function callback )
Parameters:
callback ( function ) Function to execute when the traceback occurs
Returns:
nil

Shows system cursor.


function showCursor ()
Returns:
nil

Converts the number of time passed in seconds to frames.


function timeToFrames ( number time )
Parameters:
time ( number ) The number of seconds.
Returns:
frames ( number )