Engine.EnvironmentLoad
Usage
res = Engine.EnvironmentLoad(name)
Description
Load a built-in 3D environment. Current environments are:
Parameters
| Name |
Type |
Description |
| name | string | Name of environment to load (see list above) |
Returns
number: Id of loaded environment
Engine.EnvironmentUnload
Usage
Engine.EnvironmentUnload(id)
Description
Unload an environment
Parameters
| Name |
Type |
Description |
| id | number | Id of environment to unload |
Engine.MusicSheetCreate
Usage
res = Engine.MusicSheetCreate(sheet)
Description
EXPERIMENTAL FEATURE IN PROGRESS! Not yet optimised - playback is slower than intended! Create music sequence from 'sheet' music in given sheet string. See Music Sheet documentation for the 'sheet' format.
Parameters
| Name |
Type |
Description |
| sheet | string | String of music |
Returns
number: Id of new music sheet object
Engine.MusicSheetPause
Usage
Engine.MusicSheetPause()
Description
Pause the music sheet player.
Engine.MusicSheetPlay
Usage
Engine.MusicSheetPlay(music, bpm, bank)
Description
Play music from sheet sequence created by MusicSheetCreate. All notes are selected from the specified audio bank.
Parameters
| Name |
Type |
Description |
| music | number | Music Id |
| bpm | number | Beats per minute |
| bank | number | Bank index (from 0) |
Engine.MusicSheetResume
Usage
Engine.MusicSheetResume()
Description
Resume music sheet player.
Engine.MusicSheetStop
Usage
Engine.MusicSheetStop()
Description
Stop the music player.
Engine.SetClearColor
Usage
Engine.SetClearColor(r, g, b)
Description
Set the background color. Each color component is a value between 0 and 1. White is (1, 1, 1) while black is (0,0,0).
Parameters
| Name |
Type |
Description |
| r | number | Red |
| g | number | Green |
| b | number | Blue |
Engine.GetDPadState
Usage
res = Engine.GetDPadState(name)
Description
Get state of all buttons of the named dpad. Currently only DPAD0 is supported.
Parameters
| Name |
Type |
Description |
| name | string | Name of dpad. Currently only DPAD0 is supported |
Returns
table: State of dpad. Contains fields left, right, up and down. Each direction contains isDown, isUp and isPressed
Engine.GetJoyState
Usage
res = Engine.GetJoyState(name)
Description
Get the 2D axis of the named joystick.
Parameters
| Name |
Type |
Description |
| name | string | Name of joypad, only JOY0 is supported currently. Can also be read as a dpad. Contains x, y, left, right, up and down. |
Returns
table: Joystick state table with fields x, y, left, right, up and downs. x and y are between -1.0 and 1.0. left, right, down and up have isDown, isUp and iPressed
Engine.GetTouch
Usage
res = Engine.GetTouch(idx)
Description
Get the status of the given touch
Parameters
| Name |
Type |
Description |
| idx | number | Index of touch |
Returns
table: Touch table contains fields:
state: button state table (isDown, isUp and isPressed)
x: X coordinate of touch
y: Y coordinate of touch
dx: Movement in X since last frame
dy: Movement in Y since last frame
Engine.GetTouchCount
Usage
res = Engine.GetTouchCount()
Description
Get number of touches on the touchscreen (within the Pikle screen)
Returns
number: Touch count
Engine.KeyValueGet
Usage
res = Engine.KeyValueGet(key, def)
Description
Get a string value from the persistent store. Return default value if not found.
Parameters
| Name |
Type |
Description |
| key | string | Name of item (it's key) |
| def | string | Default string value to use if not found |
Returns
string: String value of key
Engine.KeyValueGet
Usage
res = Engine.KeyValueGet(key, def)
Description
Get a number value from the persistent store. Return default value if not found.
Parameters
| Name |
Type |
Description |
| key | string | Name of item (it's key) |
| def | number | Default number value to use if not found |
Returns
number: Number value of item or 'def' if not found
Engine.KeyValueReset
Usage
res = Engine.KeyValueReset()
Description
Remove all keys and their values
Returns
boolean: True if key store reset successfully, false otherwise
Engine.KeyValueSave
Usage
res = Engine.KeyValueSave()
Description
Save all values to persistent device storage
Returns
boolean: True if key set, false otherwise
Engine.KeyValueSet
Usage
res = Engine.KeyValueSet(key, val)
Description
Set key item to a string value
Parameters
| Name |
Type |
Description |
| key | string | Item name (it's key) |
| val | string | String value |
Returns
boolean: True if key set, false otherwise
Engine.KeyValueSet
Usage
res = Engine.KeyValueSet(key, val)
Description
Set key item to a number.
Parameters
| Name |
Type |
Description |
| key | string | Item name (it's key) |
| val | number | |
Returns
boolean: True if key set, false otherwise
Engine.Render3DFirst
Usage
Engine.Render3DFirst()
Description
Switch to rendering 3D content on top of the 2D sprite and text layers
Engine.RenderSpriteLayersFirst
Usage
Engine.RenderSpriteLayersFirst()
Description
Switch to rendering all sprite and text layers before 3D content. 3D content will apppear on top.
Engine.SpriteLayerReset
Usage
Engine.SpriteLayerReset(idx, is3D)
Description
Reset position, orientation and mode of sprite layer. Use 3D mode to render sprites on a plane in AR mode.
Parameters
| Name |
Type |
Description |
| idx | number | Sprite layer index (starting from 0). Only 0 currently supported |
| is3D | boolean | true if layer should be rendered as 3D, false for default 2D behaviour. |
Engine.LEDSetChar
Usage
Engine.LEDSetChar(str)
Description
Set the LED display to an alphanumeric character (only A-Z or 0-9)
Parameters
| Name |
Type |
Description |
| str | string | First character of string will be displayed |
Engine.LEDSetMask
Usage
Engine.LEDSetMask(mask)
Description
Set the LED display using a mask value. The lowest 25 bits of 'mask' are used. Bit 0 is the bottom-right dot. Bit 24 is the top-left dot. The following code sample displays a circle on the LED display:
Engine.LEDSetMask(bit32.bor(
bit32.lshift(0x0E, 20),
bit32.lshift(0x11, 15),
bit32.lshift(0x11, 10),
bit32.lshift(0x11, 5),
0x0E
))
Parameters
| Name |
Type |
Description |
| mask | number | Integer mask (only lowest 25 bits used) |
Engine.LightEnable
Usage
Engine.LightEnable(light, en)
Description
Enable or disable a 3D light
Parameters
| Name |
Type |
Description |
| light | number | Index of light (from 0) |
| en | boolean | True to enable, false to disable |
Engine.LightEnableShadows
Usage
Engine.LightEnableShadows(light, enabled)
Description
Enable shadow-casting from a light
Parameters
| Name |
Type |
Description |
| light | number | Index of light (from 0) |
| enabled | boolean | True to cast shadows from this light, false to disable |
Engine.LightOrientation
Usage
Engine.LightOrientation(light, ax, ay, az)
Description
Set the rotation of a light
Parameters
| Name |
Type |
Description |
| light | number | Index (from 0) of light to rotate |
| ax | number | Angle about x-axis (in degrees) |
| ay | number | Angle about y-axis (in degrees) |
| az | number | Angle about z-axis (in degrees) |
Engine.LightReset
Usage
Engine.LightReset(light)
Description
Reset a 3D light back to original white, intensity and rotation
Parameters
| Name |
Type |
Description |
| light | number | Index of light (from 0) |
Engine.LightSetColor
Usage
Engine.LightSetColor(light, r, g, b)
Description
Set the color of a light
Parameters
| Name |
Type |
Description |
| light | number | Index of light (from 0) |
| r | number | Red (0.0 - 1.0) |
| g | number | Green (0.0 - 1.0) |
| b | number | Blue (0.0 - 1.0) |
Engine.LightSetIntensity
Usage
Engine.LightSetIntensity(light, intensity)
Description
Set intensity of a light
Parameters
| Name |
Type |
Description |
| light | number | Index of light (from 0) |
| intensity | number | Intensity (default 1.0) |
Engine.AngleBetween
Usage
res = Engine.AngleBetween(a, b, axis)
Description
Get the signed angle between two vectors a and b. Use axis as a reference to determine the sign of the angle.
Parameters
| Name |
Type |
Description |
| a | table | Vec3 vector object |
| b | table | Vec3 vector object |
| axis | table | Axis reference to determine sign of angle |
Returns
number: Angle between vectors (in degrees)
Engine.QuatEuler
Usage
res = Engine.QuatEuler(x, y, z)
Description
Make a quaternion using euler angles (in degrees) x, y and z
Parameters
| Name |
Type |
Description |
| x | number | Rotation about X-axis |
| y | number | Rotation about Y-axis |
| z | number | Rotation about Z-axis |
Returns
table: Quaternion
Engine.QuatMakeLookRotation
Usage
res = Engine.QuatMakeLookRotation(f, u)
Description
Make a quaternion that would cause a rotation to face target position f about up vector u
Parameters
| Name |
Type |
Description |
| f | table | Target position |
| u | table | Up vector |
Returns
table: Quaternion
Engine.QuatMultiply
Usage
res = Engine.QuatMultiply(q1, q2)
Description
Multiply two quaternions together to produce a rotation that is equivalent to q1 and q2 being applied in sequence
Parameters
| Name |
Type |
Description |
| q1 | table | First rotation |
| q2 | table | Second rotation |
Returns
table: Rotations q1 and q2 combined into one quaternion
Engine.QuatSlerp
Usage
res = Engine.QuatSlerp(q1, q2, step)
Description
Make a quaternion that is spherically interpolated between q1 and q2 by ratio step (0.5 would be a rotation half way between the two)
Parameters
| Name |
Type |
Description |
| q1 | table | Starting rotation |
| q2 | table | Target rotation |
| step | number | Ratio between the two (0.0 - 1.0) |
Returns
table: Interpolated quaternion between q1 and q2
Engine.RotateVector
Usage
res = Engine.RotateVector(a, axis, ang)
Description
Rotate vector a by angle ang about axis
Parameters
| Name |
Type |
Description |
| a | table | Vector to rotate |
| axis | table | Axis to rotate about |
| ang | number | Angle to rotate in degrees |
Returns
table: Rotated vector
Engine.Vec3Create
Usage
res = Engine.Vec3Create(x, y, z)
Description
Create a Vec3 object that has x, y and z properties.
Parameters
| Name |
Type |
Description |
| x | number | |
| y | number | |
| z | number | |
Returns
table: Vector object (Vec3)
Engine.ModelCreate
Usage
res = Engine.ModelCreate(objFile, format)
Description
Create a 3D model for use with the Object functions. The 3D model must be in OBJ or PLY format (as exported from 3D applications such as Blender).
Parameters
| Name |
Type |
Description |
| objFile | string | |
| format | string | |
Returns
number: Id of model or -1 if failed
Engine.ModelCreate
Usage
res = Engine.ModelCreate(objFile)
Description
Create a 3D model (in OBJ format) for use with the Object functions. Can use OBJ file taken directly from Blender.
Parameters
| Name |
Type |
Description |
| objFile | string | |
Returns
number: Id of model or -1 if failed
Engine.ModelDestroy
Usage
Engine.ModelDestroy(id)
Description
Destroy and release memory of 3D model
Parameters
| Name |
Type |
Description |
| id | number | Id of model |
Engine.ModelProcess
Usage
res = Engine.ModelProcess(id, dynFunc)
Description
Process all vertices of a model using given custom function. The user function will be called for every vertex of the model. See Stunt Car sample for example usage (modifying a 3D track mesh to fit a spline).
- idx: Index of vertex
- count: Number of vertices in the model
- vertex: Table of 12 vertex elements: x, y, z
function processTrackVert(idx, count, vertex)
-- Process vertex with index "idx"
-- Model has "count" vertices.
local posX, posY, posZ = v[1], v[2], v[3]
local normalX, normalY, normalZ = v[4], v[5], v[6]
local r, g, b, a = v[7], v[8], v[9], v[10]
local u, v = v[11], v[12]
end
Parameters
| Name |
Type |
Description |
| id | number | Id of 3D model created with ModelCreate(..) |
| dynFunc | table | User function to process each vertex of the 3D model |
Returns
boolean: true if model created successfully
Engine.MusicBankCount
Usage
res = Engine.MusicBankCount()
Description
Get the number of banks of music currently available in Pikle Player.
Returns
number: Number of music banks
Engine.MusicPlay
Usage
Engine.MusicPlay(bank, music)
Description
Play a music track from the Asset Library. Open the Asset Library from the Pikle Player Hub to see what built-in music is available
Parameters
| Name |
Type |
Description |
| bank | number | Bank number |
| music | number | Music number within bank |
Engine.MusicStop
Usage
Engine.MusicStop()
Description
Stop playing music
Engine.ObjectCreate
Usage
res = Engine.ObjectCreate(bank, model)
Description
Create a 3d object that renders the built-in 3D model in asset bank. See Asset Browser in Pikle Player for built-in assets
Parameters
| Name |
Type |
Description |
| bank | number | Bank number |
| model | number | Model number within bank |
Returns
number: Id of object
Engine.ObjectCreate
Usage
res = Engine.ObjectCreate(bank, model, x, y, z, rx, ry, rz)
Description
Create a 3D object to render a built-in model from the asset library. Give it position x,y,z and rotation rx, ry, rz
Parameters
| Name |
Type |
Description |
| bank | number | Bank number |
| model | number | Model number within bank |
| x | number | X position |
| y | number | Y position |
| z | number | Z position |
| rx | number | Rotation about x-axis in degrees |
| ry | number | Rotation about y-axis in degrees |
| rz | number | Rotation about z-axis in degrees |
Returns
number: Id of object
Engine.ObjectCreate
Usage
res = Engine.ObjectCreate(model, x, y, z, rx, ry, rz)
Description
Create a 3d object in world space to render the given model with rotation.
Parameters
| Name |
Type |
Description |
| model | number | Model id |
| x | number | X position |
| y | number | Y position |
| z | number | Z position |
| rx | number | Rotation about x-axis |
| ry | number | Rotation about y-axis |
| rz | number | Rotation about z-axis |
Returns
number: Id of object
Engine.ObjectCreateCollisionMesh
Usage
Engine.ObjectCreateCollisionMesh(obj, convex)
Description
Create a collision mesh for an object.
Parameters
| Name |
Type |
Description |
| obj | number | Object Id |
| convex | boolean | True to create a convex collider, false otherwise |
Engine.ObjectDestroy
Usage
Engine.ObjectDestroy(id)
Description
Destroy object and free memory
Parameters
| Name |
Type |
Description |
| id | number | Id of object to destroy |
Engine.ObjectEnable
Usage
Engine.ObjectEnable(id, en)
Description
Enable or disable a 3D object. If disabled, it's model will not be rendered and the object's physics will be paused
Parameters
| Name |
Type |
Description |
| id | number | Id of object |
| en | boolean | True to enable, false to disable |
Engine.ObjectGetDown
Usage
res = Engine.ObjectGetDown(id)
Description
Get down-direction vector of object.
Parameters
| Name |
Type |
Description |
| id | number | Object Id |
Returns
table: Down direction vector
Engine.ObjectGetForward
Usage
res = Engine.ObjectGetForward(id)
Description
Get forward direction (local Z axis) of 3D object
Parameters
| Name |
Type |
Description |
| id | number | Object Id |
Returns
table: Forward direction vector
Engine.ObjectGetPosition
Usage
res = Engine.ObjectGetPosition(id)
Description
Get position of object
Parameters
| Name |
Type |
Description |
| id | number | Object Id |
Returns
table: World position as a Vec3
Engine.ObjectGetRight
Usage
res = Engine.ObjectGetRight(id)
Description
Get right-side direction vector (negated it represents the left)
Parameters
| Name |
Type |
Description |
| id | number | Object Id |
Returns
table: Right direction vector
Engine.ObjectGetRotation
Usage
res = Engine.ObjectGetRotation(id)
Description
Get rotation of object as euler angles in degrees.
Parameters
| Name |
Type |
Description |
| id | number | Object Id |
Returns
table: Orientation vector in degrees
Engine.ObjectGetUp
Usage
res = Engine.ObjectGetUp(id)
Description
Get up vector direction of 3D object.
Parameters
| Name |
Type |
Description |
| id | number | Object Id |
Returns
table: Up direction vector
Engine.ObjectLookat
Usage
Engine.ObjectLookat(id, x, y, z)
Description
Rotate object to face target position
Parameters
| Name |
Type |
Description |
| id | number | Object Id |
| x | number | World target X position |
| y | number | World target Y position |
| z | number | World target Z position |
Engine.ObjectMove
Usage
Engine.ObjectMove(id, tx, ty, tz)
Description
Move an object by amount (tx, ty, tz)
Parameters
| Name |
Type |
Description |
| id | number | Object Id |
| tx | number | Amount to move in x-axis |
| ty | number | Amount to move in y-axis |
| tz | number | Amount to move in z-axis |
Engine.ObjectMoveForward
Usage
Engine.ObjectMoveForward(id, f)
Description
Move an object a distance along it's forward vector
Parameters
| Name |
Type |
Description |
| id | number | Object Id |
| f | number | Amount to move |
Engine.ObjectSetColor
Usage
Engine.ObjectSetColor(id, r, g, b)
Description
Set the color of an individual object
Parameters
| Name |
Type |
Description |
| id | number | Object Id |
| r | number | Red (0.0 - 1.0) |
| g | number | Green (0.0 - 1.0) |
| b | number | Blue (0.0 - 1.0) |
Engine.ObjectSetPosition
Usage
Engine.ObjectSetPosition(id, tx, ty, tz)
Description
Set the world position of an object
Parameters
| Name |
Type |
Description |
| id | number | Object Id |
| tx | number | X position |
| ty | number | Y position |
| tz | number | Z position |
Engine.ObjectSetRotation
Usage
Engine.ObjectSetRotation(id, r)
Description
Set rotation of an object using a quaternion
Parameters
| Name |
Type |
Description |
| id | number | Object Id |
| r | table | Rotation to be applied |
Engine.ObjectSetRotation
Usage
Engine.ObjectSetRotation(id, rx, ry, rz)
Description
Set rotation of an object
Parameters
| Name |
Type |
Description |
| id | number | Object Id |
| rx | number | Rotation in degrees aout x-axis |
| ry | number | Rotation in degrees aout y-axis |
| rz | number | Rotation in degrees aout z-axis |
Engine.ObjectSetScale
Usage
Engine.ObjectSetScale(id, sx, sy, sz)
Description
Set scale of an object
Parameters
| Name |
Type |
Description |
| id | number | Object Id |
| sx | number | X scale |
| sy | number | Y scale |
| sz | number | Z scale |
Engine.ObjectSetTexture
Usage
Engine.ObjectSetTexture(id, bank, asset)
Description
Change the texture of the object to the texture from the sprite bank
Parameters
| Name |
Type |
Description |
| id | number | Object Id |
| bank | number | Bank number |
| asset | number | Asset number with bank |
Engine.ObjectSetVisible
Usage
Engine.ObjectSetVisible(id, vis)
Description
Set visibility of the 3D model
Parameters
| Name |
Type |
Description |
| id | number | Id of object |
| vis | boolean | True if visible, false otherwise |
Engine.RaycastPoll
Usage
res = Engine.RaycastPoll(requestId)
Description
Check for a raycast result. Result (table) contains the following properties:
px, py, pz: world space position of hit
nx, ny, nz: normal vector of surface hit by ray
distance: distance from ray start to hit location
Parameters
| Name |
Type |
Description |
| requestId | number | |
Returns
table: Hit result of type RaycastResult (see above)
Engine.RaycastRequest
Usage
res = Engine.RaycastRequest(ray)
Description
Request a raycast. A ray will be sent through the scene to see if any collidable objects are found. Objects without a collision mesh will not be found. Result is NOT available immediately. You must check for a result using RaycastPoll. Ray table contains:
px, py, pz: start position of ray
rx, ry, rz: ray direction
maxDistance: distance to shoot the ray (objects won't be detected beyond this distance)
Parameters
| Name |
Type |
Description |
| ray | table | Ray information (see above) |
Returns
number: Id of request
Engine.ScriptGetCount
Usage
res = Engine.ScriptGetCount()
Description
Return the number of scripts on this device.
Returns
number: Total script count (built-in samples + user scripts)
Engine.ScriptGetName
Usage
res = Engine.ScriptGetName(idx)
Description
Get the name of the script with the given index number.
Parameters
| Name |
Type |
Description |
| idx | number | Index of script. First script is at index 1. |
Returns
string: Name (string) of script
Engine.ScriptIsUserFile
Usage
res = Engine.ScriptIsUserFile(idx)
Description
Return true if the script at index 'idx' is a user script or a builtin script.
Parameters
| Name |
Type |
Description |
| idx | number | Index (first script is at index 1) |
Returns
boolean: true if user script, false otherwise
Engine.ScriptRun
Usage
Engine.ScriptRun(idx)
Description
Launch script with given index 'idx'. Warning: active script will be lost if not saved.
Parameters
| Name |
Type |
Description |
| idx | number | Index of script (starting at 1) |
Engine.SpriteAnimateAll
Usage
Engine.SpriteAnimateAll(dt)
Description
Make all sprite animation
Parameters
| Name |
Type |
Description |
| dt | number | Amount of time to a |
Engine.SpriteColor
Usage
Engine.SpriteColor(idx, r, g, b, a)
Description
Set the color of a sprite
Parameters
| Name |
Type |
Description |
| idx | number | Index of sprite (0 to 255) |
| r | number | Red (0.0 to 1.0) |
| g | number | Green (0.0 to 1.0) |
| b | number | Blue (0.0 - 1.0) |
| a | number | Alpha (0.0 - 1.0) where 0.0 is transparent and 1.0 is opaque |
Engine.SpriteCreateAnim
Usage
res = Engine.SpriteCreateAnim(duration, frames)
Description
Create a sprite animation with a duration and a number of frames (images). Each frame specifies an images bank and shape number. A two-frame animation [0, 10, 1, 20] uses two images, shape 10 from bank 0 and shape 20 from bank 1.
Parameters
| Name |
Type |
Description |
| duration | number | Duration in seconds |
| frames | table | Array of frame data. |
Returns
number: Id of sprite animation
Engine.SpriteDestroyAnim
Usage
Engine.SpriteDestroyAnim(id)
Description
Destroy and release instance of sprite animation.
Parameters
| Name |
Type |
Description |
| id | number | Id of animation created using SpriteCreateAnim |
Engine.SpriteEnable
Usage
Engine.SpriteEnable(idx, en)
Description
Enable or disable a single sprite.
Parameters
| Name |
Type |
Description |
| idx | number | Index of sprite to enable/disable (0 to 255) |
| en | boolean | true to enable, false to disable |
Engine.SpriteEnableAll
Usage
Engine.SpriteEnableAll(en)
Description
Enable or disable all 256 sprites (0 to 255).
Parameters
| Name |
Type |
Description |
| en | boolean | True to enable, false to disable |
Engine.SpriteFontCreate
Usage
res = Engine.SpriteFontCreate(fontDef)
Description
Create a font using sprites. In the asset library there are sprites of alphanumeric characters. These can be used to display words, numbers and phrases. Each letter is a sprite.
Sprite fonts are described using a table with the following properties:
spriteBank: Bank index number (starting from 0)
a: Sprite index to use for the letter 'a' (remaining lowercase letters to follow in sequence)
A: Sprite index to use for the uppercase letter 'A' (remaining uppercase letters to follow in sequence)
Zero: Sprite index for the digit '0' (remaining digits will follow in sequence)
Kerning: Number to adjust the spacing between sprites
Size: Sprite scale will be set to this size
Parameters
| Name |
Type |
Description |
| fontDef | table | Font description that controls how sprites are positioned |
Returns
number: Id of new sprite font
Engine.SpriteFontLabel
Usage
res = Engine.SpriteFontLabel(fontId, firstSpr, label, x, y, z)
Description
Display a text label using sprites based on the provided font description.
Parameters
| Name |
Type |
Description |
| fontId | number | Font id as returned from SpriteFontCreate |
| firstSpr | number | Index of sprite to use for the first character (subsequent characters will use sprite indices in order) |
| label | string | Alphanumeric text to display |
| x | number | X position |
| y | number | Y position |
| z | number | Z position (used for ordering only) |
Returns
number: Number of sprites used
Engine.SpriteGetPosition
Usage
res = Engine.SpriteGetPosition(idx)
Description
Get 3D position of sprite
Parameters
| Name |
Type |
Description |
| idx | number | Index of sprite (0 to 255) |
Returns
table: Position of sprite in world space
Engine.SpriteGroupAllocSprite
Usage
res = Engine.SpriteGroupAllocSprite(grpId)
Description
Get an unused sprite from the sprite group.
Parameters
| Name |
Type |
Description |
| grpId | number | Group Id |
Returns
number: Index of sprite
Engine.SpriteGroupCreate
Usage
res = Engine.SpriteGroupCreate(min, count)
Description
Create a sprite group.
Parameters
| Name |
Type |
Description |
| min | number | Index of first sprite |
| count | number | Number of sprites in the group |
Returns
number: Id of sprite group
Engine.SpriteGroupDestroy
Usage
Engine.SpriteGroupDestroy(grpId)
Description
Destroy the group. This does not affect the sprites in the group, it just releases the object from memory.
Parameters
| Name |
Type |
Description |
| grpId | number | Group Id |
Engine.SpriteGroupEnable
Usage
Engine.SpriteGroupEnable(grpId, en)
Description
Enable or disable all sprites in the group
Parameters
| Name |
Type |
Description |
| grpId | number | Group Id |
| en | boolean | True to enable all sprites, false to disable all sprites |
Engine.SpriteGroupFreeAllSprites
Usage
Engine.SpriteGroupFreeAllSprites(grpId)
Description
Mark all sprites in the group as unused.
Parameters
| Name |
Type |
Description |
| grpId | number | Group Id |
Engine.SpriteGroupFreeSprite
Usage
Engine.SpriteGroupFreeSprite(grpId, sprId)
Description
Mark a sprite in the group as unused. Once unused, it can be allocated again via SpriteGroupAllocSprite.
Parameters
| Name |
Type |
Description |
| grpId | number | Group Id |
| sprId | number | Sprite id to mark as unused |
Engine.SpriteGroupMovePosition
Usage
Engine.SpriteGroupMovePosition(grpId, dx, dy, dz)
Description
Move the position of all sprites by (dx,dy,dz).
Parameters
| Name |
Type |
Description |
| grpId | number | Group Id |
| dx | number | Change in X position |
| dy | number | Change in Y position |
| dz | number | Change in Z position |
Engine.SpriteGroupSetColor
Usage
Engine.SpriteGroupSetColor(grpId, r, g, b, a)
Description
Set the color of all sprites in a sprite group.
Parameters
| Name |
Type |
Description |
| grpId | number | Group Id |
| r | number | Red (0.0 - 1.0) |
| g | number | Green (0.0 - 1.0) |
| b | number | Blue (0.0 - 1.0) |
| a | number | Alpha (0.0 - 1.0) |
Engine.SpriteGroupSetPosition
Usage
Engine.SpriteGroupSetPosition(grpId, x, y, z)
Description
Set the position of all sprites in the group to the same (x,y,z). (0,0,0) is the center of the screen.
Parameters
| Name |
Type |
Description |
| grpId | number | Group Id |
| x | number | X position |
| y | number | Y position |
| z | number | Z position |
Engine.SpriteGroupSetScale
Usage
Engine.SpriteGroupSetScale(grpId, sx, sy, sz)
Description
Set the scale of all sprites in the group to (sx,sy,sz). (1,1,1) is default scale.
Parameters
| Name |
Type |
Description |
| grpId | number | Group Id |
| sx | number | X scale |
| sy | number | Y scale |
| sz | number | Z scale |
Engine.SpriteGroupSetShape
Usage
Engine.SpriteGroupSetShape(grpId, bank, spr)
Description
Set all sprites in the group to the same image from the asset library
Parameters
| Name |
Type |
Description |
| grpId | number | Group Id |
| bank | number | Sprite image bank index (from 0) |
| spr | number | Sprite asset index (from 0) |
Engine.SpriteGroupSetSortingOrder
Usage
Engine.SpriteGroupSetSortingOrder(grpId, order)
Description
Set sorting order of all sprites in a sprite group. Higher order sprites are drawn on top of lower order sprites.
Parameters
| Name |
Type |
Description |
| grpId | number | Group Id |
| order | number | Rendering order |
Engine.SpriteIsColliding
Usage
res = Engine.SpriteIsColliding(idx1, idx2)
Description
Check if the bounds of two sprites are overlapping.
Parameters
| Name |
Type |
Description |
| idx1 | number | First sprite index (0 to 255) |
| idx2 | number | Second sprite index (0 to 255) |
Returns
boolean: true if colliding, false otherwise
Engine.SpriteIsEnabled
Usage
res = Engine.SpriteIsEnabled(idx)
Description
Check if a sprite is enabled
Parameters
| Name |
Type |
Description |
| idx | number | Index of sprite (0 to 255) |
Returns
boolean: true if enabled, false otherwise
Engine.SpriteLayerLocalRotation
Usage
Engine.SpriteLayerLocalRotation(layer, rx, ry, rz)
Description
Set local rotation of sprite layer (rotation in degrees). Does not take affect until end of frame.
Parameters
| Name |
Type |
Description |
| layer | number | Layer number starting from 0. [Only 0 supported currently] |
| rx | number | Rotation about X-axis |
| ry | number | Rotation about Y-axis |
| rz | number | Rotation about Z-axis |
Engine.SpriteLayerLocalScale
Usage
Engine.SpriteLayerLocalScale(layer, sx, sy, sz)
Description
Set scale of sprite layer. Does not take affect until frame is rendered.
Parameters
| Name |
Type |
Description |
| layer | number | Layer number starting from 0 [Only 0 supported currently] |
| sx | number | Scale in X axis |
| sy | number | Scale in Y axis |
| sz | number | Scale in Z axis |
Engine.SpriteLayerRotate
Usage
Engine.SpriteLayerRotate(layer, world, rx, ry, rz)
Description
Rotate sprite layer (rotation in degrees)
Parameters
| Name |
Type |
Description |
| layer | number | Layer number starting from 0 [Only 0 supported currently] |
| world | boolean | true to rotate about world axis, false to rotate around local axis |
| rx | number | Rotation about X-axis |
| ry | number | Rotation about Y-axis |
| rz | number | Rotation about Z-axis |
Engine.SpriteMove
Usage
Engine.SpriteMove(idx, dx, dy, dz)
Description
Move a sprite
Parameters
| Name |
Type |
Description |
| idx | number | Index of sprite (0 to 255) |
| dx | number | Amount to move in X direction |
| dy | number | Amount to move in Y direction |
| dz | number | Amount to move in Z direction |
Engine.SpriteOrder
Usage
Engine.SpriteOrder(idx, order)
Description
Set order of sprite within it's sprite layer. Use high order number to render a sprite on top of lower-ordered sprites.
Parameters
| Name |
Type |
Description |
| idx | number | Index of sprite (0 to 255) |
| order | number | Order number (use high order number to render sprite on top) |
Engine.SpritePlayAnim
Usage
Engine.SpritePlayAnim(sprId, restart)
Description
Start playing sprite animation on sprite
Parameters
| Name |
Type |
Description |
| sprId | number | Sprite index (0 to 255) |
| restart | boolean | true if animation should start from the beginning |
Engine.SpritePosition
Usage
Engine.SpritePosition(idx, x, y, z)
Description
Set position of sprite
Parameters
| Name |
Type |
Description |
| idx | number | Index of sprite (0 to 255) |
| x | number | X position |
| y | number | Y position |
| z | number | Z position |
Engine.SpriteRotation
Usage
Engine.SpriteRotation(idx, x, y, z)
Description
Set rotation (in degrees) of sprite
Parameters
| Name |
Type |
Description |
| idx | number | Index of sprite (0 to 255) |
| x | number | X rotation |
| y | number | Y rotation |
| z | number | Z rotation |
Engine.SpriteScale
Usage
Engine.SpriteScale(idx, x, y, z)
Description
Set scale of sprite
Parameters
| Name |
Type |
Description |
| idx | number | Index of sprite (0 to 255) |
| x | number | X scale |
| y | number | Y scale |
| z | number | Z scale |
Engine.SpriteSetAnim
Usage
Engine.SpriteSetAnim(sprId, animId, loop)
Description
Set sprite to use animation created with SpriteCreateAnim
Parameters
| Name |
Type |
Description |
| sprId | number | Sprite index (0 to 255) |
| animId | number | Id of animation |
| loop | boolean | true if animation should loop |
Engine.SpriteSetAnim
Usage
Engine.SpriteSetAnim(sprId, animId, play, loop)
Description
Set sprite to use animation created with SpriteCreateAnim
Parameters
| Name |
Type |
Description |
| sprId | number | Sprite index (0 to 255) |
| animId | number | Id of animation |
| play | boolean | true if animation should start playing immediately |
| loop | boolean | true if animation should loop |
Engine.SpriteSetAnimLoop
Usage
Engine.SpriteSetAnimLoop(sprId, loop)
Description
Set sprite to loop it's animation
Parameters
| Name |
Type |
Description |
| sprId | number | Sprite index (0 to 255) |
| loop | boolean | true if animation should loop, false otherwise |
Engine.SpriteShape
Usage
Engine.SpriteShape(idx, bank, shape)
Description
Set sprite image
Parameters
| Name |
Type |
Description |
| idx | number | Index of sprite (0 to 255) |
| bank | number | Bank number (from 0) |
| shape | number | Shape number (from 0) |
Engine.SpriteShape
Usage
Engine.SpriteShape(idx, shape)
Description
Set sprite image without changing bank number.
Parameters
| Name |
Type |
Description |
| idx | number | Index of sprite (0 to 255) |
| shape | number | Shape index from 0 |
Engine.APIVersion
Usage
res = Engine.APIVersion()
Description
Get the API version.
Returns
string: Version string in format Major.Minor.Patch (e.g. 0.0.1)
Engine.Reset
Usage
Engine.Reset()
Description
Reset engine state back to defaults. Clears all sprites and other engine objects.
Engine.ClearText
Usage
Engine.ClearText()
Description
Clear the fixed-width text layer.
Engine.NumTextColumns
Usage
res = Engine.NumTextColumns()
Description
Get the number of columns in the fixed-width text layer
Returns
number: Column count
Engine.NumTextRows
Usage
res = Engine.NumTextRows()
Description
Get the number of rows in the fixed-width text layer
Returns
number: Row count
Engine.SetCursorPosition
Usage
Engine.SetCursorPosition(x, y)
Description
Set the position of the cursor on the fixed-width text layer. Top-left of screen is at (0,0).
Parameters
| Name |
Type |
Description |
| x | number | Integer value between 0 and GetTextColumns()-1 |
| y | number | Integer value between 0 and GetTextRows()-1 |
Engine.SetTextColor
Usage
Engine.SetTextColor(r, g, b, a)
Description
Set the color of the fixed-width text layer. Each color component is a value between 0 and 1. White is (1, 1, 1) while black is (0,0,0). Alpha value a is 0 for transparent, 1 for solid.
Parameters
| Name |
Type |
Description |
| r | number | Red |
| g | number | Green |
| b | number | Blue |
| a | number | Alpha |
Engine.Text
Usage
Engine.Text(t)
Description
Draw text t at current cursor position.
Parameters
| Name |
Type |
Description |
| t | string | Text string |
Engine.Text
Usage
Engine.Text(col, row, t)
Description
Draw some text t at position (x,y).
Parameters
| Name |
Type |
Description |
| col | number | Integer column value |
| row | number | Integer row value |
| t | string | String text |
Engine.TextClear
Usage
Engine.TextClear()
Description
Clear the fixed-width text layer.
Engine.TextNumColumns
Usage
res = Engine.TextNumColumns()
Description
Get the number of columns in the fixed-width text layer
Returns
number: Column count
Engine.TextNumRows
Usage
res = Engine.TextNumRows()
Description
Get the number of rows in the fixed-width text layer
Returns
number: Row count
Engine.TextOrder
Usage
Engine.TextOrder(order)
Description
Set the rendering order of the fixed-width text layer. Determines whether other items such as sprites will be rendered on top or underneath.
Parameters
| Name |
Type |
Description |
| order | number | Integer value of order |
Engine.TextSetColor
Usage
Engine.TextSetColor(r, g, b, a)
Description
Set the color of the fixed-width text layer. Each color component is a value between 0 and 1. White is (1, 1, 1) while black is (0,0,0). Alpha value a is 0 for transparent, 1 for solid.
Parameters
| Name |
Type |
Description |
| r | number | Red |
| g | number | Green |
| b | number | Blue |
| a | number | Alpha |
Engine.TextSetCursorPosition
Usage
Engine.TextSetCursorPosition(x, y)
Description
Set the position of the cursor on the fixed-width text layer. Top-left of screen is at (0,0).
Parameters
| Name |
Type |
Description |
| x | number | Integer value between 0 and GetTextColumns()-1 |
| y | number | Integer value between 0 and GetTextRows()-1 |
Engine.TileCellSize
Usage
Engine.TileCellSize(layer, w, h)
Description
Set cell size of tile layer
Parameters
| Name |
Type |
Description |
| layer | number | Layer id (only 0 currently supported) |
| w | number | Width in pixels |
| h | number | Height in pixels |
Engine.TileClear
Usage
Engine.TileClear(layer, x, y)
Description
Clear tile at specific location
Parameters
| Name |
Type |
Description |
| layer | number | Layer id |
| x | number | Column index |
| y | number | Row index |
Engine.TileClearLayer
Usage
Engine.TileClearLayer(layer)
Description
Clear all tiles from a tile layer
Parameters
| Name |
Type |
Description |
| layer | number | |
Engine.TileEnable
Usage
Engine.TileEnable(en)
Description
Enable or disable tile layering system
Parameters
| Name |
Type |
Description |
| en | boolean | |
Engine.TileLayerEnable
Usage
Engine.TileLayerEnable(layer, en)
Description
Enable or disable individual tile layer
Parameters
| Name |
Type |
Description |
| layer | number | Layer id (only 0 supported) |
| en | boolean | true to enable layer, false to disable the layer |
Engine.TileSet
Usage
Engine.TileSet(layer, x, y, bank, tile)
Description
Set a tile on the tile layer
Parameters
| Name |
Type |
Description |
| layer | number | Layer id |
| x | number | Tile position (column) |
| y | number | Tile position (row) |
| bank | number | Bank location for tile image |
| tile | number | Index of tile (0=empty space) |
Engine.TileSetBlock
Usage
Engine.TileSetBlock(layer, x, y, sizeX, sizeY, palette, tileBlock)
Description
Set a block of tiles at once
Parameters
| Name |
Type |
Description |
| layer | number | Layer id |
| x | number | Column position in tile map |
| y | number | Row position in tile map |
| sizeX | number | Horizontal size of block |
| sizeY | number | Vertical size of block |
| palette | number | Bank index |
| tileBlock | table | Array if tile indices |
Engine.TileSetLayerScale
Usage
Engine.TileSetLayerScale(layer, scale)
Description
Set scale of a tile layer
Parameters
| Name |
Type |
Description |
| layer | number | Layer id |
| scale | number | Scale (1.0 = normal) |
Engine.TileSetTileColor
Usage
Engine.TileSetTileColor(layer, x, y, r, g, b, a)
Description
Set color of an individual tile
Parameters
| Name |
Type |
Description |
| layer | number | Layer id |
| x | number | Column position |
| y | number | Row position |
| r | number | Red (0.0 - 1.0) |
| g | number | Green (0.0 - 1.0) |
| b | number | Blue (0.0 - 1.0) |
| a | number | Alpha (0.0 - 1.0) |
Engine.TileSetTileScale
Usage
Engine.TileSetTileScale(layer, x, y, scaleX, scaleY, scaleZ)
Description
Set the scale of a single tile
Parameters
| Name |
Type |
Description |
| layer | number | Layer id |
| x | number | Column position |
| y | number | Row position |
| scaleX | number | Scale in X-axis |
| scaleY | number | Scale in Y-axis |
| scaleZ | number | Scale in Z-axis |
Engine.TileSortingOrder
Usage
Engine.TileSortingOrder(layer, order)
Description
Set sorting order of individual tile layer (affects which layers render on top of other layers)
Parameters
| Name |
Type |
Description |
| layer | number | Layer id |
| order | number | Render order |
Engine.GameTime
Usage
res = Engine.GameTime()
Description
Get current game running time in seconds (starts at 0.0)
Returns
number: Time (age) of game in seconds
Engine.TimeStep
Usage
res = Engine.TimeStep()
Description
Get time elapsed since last frame.
Returns
number: Elapsed time in seconds