-
Notifications
You must be signed in to change notification settings - Fork 17
Core_API_Manual
This page shows documents of core API of LuaSTG, including Plus and X version.
To get original API manual of LuaSTGPlus, please visit here.
To get full API document of LuaSTG-x, please visit here. It's better for LuaSTG-x users to use this document since many functions are extended.
Mark | Description |
---|---|
[P] | This API is avalible in LuaSTGPlus. |
[X] | This API is avalible in LuaSTG-x. |
[static] | This API is a static function. |
(P) | Following descriptions only apply for LuaSTGPlus. |
(X) | Following descriptions only apply for LuaSTG-x. |
[P] [X]
Holds API functions and many script stuff. Functions will be exported to global space at launch.
table
[P]
Holds command line arguments as an array of string.
table
[X]
Holds command line arguments as an array of string.
table
[P] [X] [static] [deprecated in X]
Set the engine windowed or full-screen. true for windowed and false for full-screen. Default is true.
- (P) Can only be invoked during launch instead of runtime.
isWindowed boolean
[P] [X] [static]
Set target FPS. Default is 60.
- (P) Can only be invoked during launch instead of runtime.
targetFPS number
[P] [X] [static]
Get current FPS.
number
[P] [X] [static]
Set V-Sync. Default is true.
- (P) Can only be invoked during launch instead of runtime.
isEnable boolean
[P] [X] [static]
Set window resolution (size) if game is windowed. Default is 640, 480.
- (P) Can only be invoked during launch instead of runtime.
width number
height number
[P] [X] [static]
Change video parameters. Returns true if success, otherwise returns false and restore last parameters.
- (P) Can only be invoked during runtime.
width number
height number
windowed boolean
vsync boolean
boolean
[P] [X] [static]
Set if the mouse cursor is displayed in game window.
- (P) Default is false.
- (X) Default is true.
boolean
[P] [X] [static]
Set the caption of window.
- (P) Default is "LuaSTGPlus".
- (X) Default is "LuaSTG-x".
title string
[P] [X] [static]
Write string to log file.
string string
[P] [X] [static]
- (P) Write values to log file.
- (X) Print values to console on desktop platforms. Write values to log file on mobile platforms.
...
[P] [X] [static]
Load zip pack at path with an optional password.
Will throw an error if failed.
Zip pack loaded later will have higher priority. So you can override files in previous packs.
Zip file will be occupied after loaded.
Files required by engine will be searched in packs at first, then local path.
path string
password string [optional]
[P] [X] [static]
Unload zip pack loaded at path.
Will NOT throw an error if failed.
path string
[P] [X] [static]
Extract files in pack to local path.
Will throw an error if failed.
path string
target string
[P] [X] [static]
Execute script at path. Similar to dofile() of Lua.
Will throw an error if script not exists, failed to compile or failed to execute.
path string
[P] [X] [static] [deprecated in X]
- (P) Set the loading picture.
Will use default picture if failed or path not passed.
- (X) Do nothing.
path string [optional] Path of picture file.
[P] [X] [static]
Get game object count.
number
[P] [X] [static]
Update all game objects.
Do not invoke in coroutine.
Update properties in the following order:
vx += ax
vy += ay
x += vx
y += vy
rot += omiga
Update paritle system if there is
[P] [X] [static]
Render all game objects. Will invoke rander() callback one by one.
Object with smaller layer property will be rendered first.
Do not invoke in coroutine.
[P] [X] [static]
Set boundary of stage.
left number
right number
bottom number
top number
[P] [X] [static]
Do boundary check and mark objects outside boundary as del status.
An object will not be marked if bound property is false.
Do not invoke in coroutine.
[P] [X] [static]
Do collision chekc on group A and B.
If an object (in group) A collides another object (in group) B, its colli() callback will be invoked and the other object will be passed as parameter.
-
(P) A and B are group IDs.
-
(X) A and B can be either group ID or object.
Do not invoke in coroutine.
A number/object
B number/object
[P] [X] [static]
Update following properties of all objects: dx, dy, lastx, lasty, rot (when navi is true).
Do not invoke in coroutine.
[P] [X] [static]
Update following properties of all objects: timer, ani_timer. Trim objects marked as del or kill.
Do not invoke in coroutine.
You can set status property of an object to "normal" to preserve it.
[P] [X] [static]
Create a game object.
Create a game object based on class and invoke init() callback.
Created object will have following properties:
Property | Description |
---|---|
x, y | coordinates |
dx, dy | difference of coordinates from last update (read-only) |
rot | orientation (in degrees) |
omiga | angular velocity of orientation |
timer | update counter |
vx, vy | velocity |
ax, ay | acceleration |
layer | render layer |
group | collision group |
hide | if object will not be rendered |
bound | if object will be marked at boundary check |
navi | if orientation will be updated according to velocity |
colli | if object will be involved in collision check |
status | status of object, can be "del", "kill" or "normal" |
hscale, vscale | scale of horizontal and verticle |
class | class of the object |
a, b | size of collision box |
rect | if collision box is rectangle |
img | name of renderable resource on the object |
ani | animation timer (read-only) |
Index 1 and 2 of the object will be class and internal ID, do not modify them.
class should have following properties:
is_class = true
[1] = init(object, ...) callback
[2] = del(object, ...) callback
[3] = frame(object) callback
[4] = render(object) callback
[5] = colli(object, object) callback
[6] = kill(object, ...) callback
Callbacks will be invoked when corresponding event happens.
The upper limit of object count is 32768. An error will be thrown if it exceeds.
class table
[P] [X] [static]
Mark object as del status and invoke del() callback.
Parameters passed after object will be passed to del() callback.
object
...
[optional]
[P] [X] [static]
Mark object as kill status and invoke kill() callback.
Parameters passed after object will be passed to kill() callback.
object
...
[optional]
[P] [X] [static]
Check if object is valid (not trimmed).
object
[P] [X] [static]
Returns magnitude and direction (in degrees) of object velocity.
object
number,number
[P] [X] [static]
Set magnitude and direction (in degrees) of object velocity. Will update rot property if updateRot is true.
object object
magnitude number
direction number
updateRot boolean
[P] [X] [static]
Set parameters of the renderable resource bind to object.
object
blend string
a number
r number
g number
b number
[P] [X] [static]
Returns angle of two objects in degrees.
a object
b object
number
[P] [X] [static]
Returns angle of two points in degrees.
x1 number
y1 number
x2 number
y2 number
number
[P] [X] [static]
Returns distance between two objects.
a object
b object
number
[P] [X] [static]
Returns distance between (x1,y1) and (x2,y2).
x1 number
y1 number
x2 number
y2 number
number
[P] [X] [static]
Check if position of object is in the given range.
object
left number
right number
top number
bottom number
boolean
[P] [X] [static]
Trim all game objects immediately.
[P] [X] [static]
Default render function for a game object.
object
[P] [X] [static]
Iterates objects in a group if groupid is valid, otherwise iterates all objects.
This is manual version of ObjList().
groupid number
id number
number,object
[P] [X] [static]
Returns an iterator that go through objects in a group.
Example
for _, obj in ObjList(GROUP_ITEM) do ... end
groupid number
function
[P] [X] [static]
Start particle emitter on object.
object
[P] [X] [static]
Stop particle emitter on object.
object
[P] [X] [static]
Returns current particle count on object.
object
number
[P] [X] [static]
Get particle emit frequency on object (count per second).
Particle emitter will always step by 1/60 seconds.
object
[P] [X] [static]
Set particle emit frequency on object (count per second).
object
count
There are two resource pool provided by engine: global and stage. They are managed separately.
A resource is identified by its name (a string). Name should be unique in a pool.
All load function will load resource into current activated pool. Resource will be find in stage pool first, then global pool.
(P) Resource types:
- Texture
- Image
- Animation
- Music
- Sound
- Particle
- Texture font
- TTF font
- Shader
(X) Resource types:
- Texture
- Image
- Animation
- Music
- Sound
- Particle
- Font
- Shader
- Render target
Shader
(P) Shaders are in FX format of D3D9, written in HLSL. They use "binding" annotations to accept variables from lua scripts.
(X) Shaders can be fragment and/or vertex shader in GLSL. They use uniforms to accept variables from lua scripts.
Acceptable lua variables:
string: interpreted as (name of) texture
number: interpreted as a float value
lstg::Color: interpreted as a float4 value
(P) Shader can only be used for post effect.
(X) Shader can be used for post effect and RenderMode of each object.
RenderTarget
RenderTarget will always be the same size as game resolution.
Note that a RenderTarget can be both input and output of rendering. Do input and output at the same time may cause error and the engine dose not check that.
[P] [X] [static]
Clear a resources pool. poolType can be "global" or "stage".
If a resource is in use, it will not be released until all usages are end.
poolType string
[P] [X] [static]
Remove a resource from a pool. poolType can be "global" or "stage".
If a resource is in use, it will not be released until all usages are end.
poolType string
resType number Resource type code
name string
[P] [X] [static]
Returns name of the pool where a resource is located. Usually used to check if a resource exists.
Will search in global pool at first, then stage pool.
Returns nil if resource not exists.
type number
name string
string
[P] [X] [static]
Returns arrays of all resource names in global and stage pool.
type number Resource type code
table, table
[P] [X] [static]
Returns width and height of a texture resource.
name string
number, number
[P] [X] [static]
Load a texture resource from file.
name string
path string
mipmap boolean [optional] Default is false
[P] [X] [static]
Load a image resource from a texture resource.
-
x, y specifies left-top of the image in texture coordinates (in pixels).
-
w, h specifies width and height of the image (in pixels).
-
a, b, rect specifies parameters of the collision box.
When a image is assigned to img property of an object, collision box parameters will be assigned to the object.
name string
tex_name string
x number
y number
w number
h number
a number [optional]
b number [optional]
rect boolean [optional]
[P] [X] [static]
Set parameters of a image resource. Optional vertex color parameters can be 1 or 4.
Available blendMode:
"" default, equals to "mul+alpha", default mode
"mul+add" multiplication for vertex color, addition for blend
"mul+alpha" multiplication for vertex color, alpha for blend
"mul+sub" multiplication for vertex color, subtraction for blend
"mul+rev" multiplication for vertex color, reverse subtraction for blend
"add+add" addition for vertex color, addition for blend
"add+alpha" addition for vertex color, alpha for blend
"add+sub" addition for vertex color, subtraction for blend
"add+rev" addition for vertex color, reverse subtraction for blend
name string
blendMode string
vertexColor1 lstg::Color [optional]
vertexColor2 lstg::Color [optional]
vertexColor3 lstg::Color [optional]
vertexColor4 lstg::Color [optional]
[P] [X] [static]
Set center of an image resource to (x, y) relative to its left-top.
name string
x number
y number
[P] [X] [static]
Load an animation resource.
-
x, y specifies top-left coordinates of the first frame.
-
w, h specifies width and height of one frame.
-
n, m specifies number of columns and rows.
-
interval specifies played interval in frames.
-
a, b, rect specifies parameters of the collision box.
Animations are always played repeatedly.
name string
tex_name string
x, y number, number
w, h number, number
n, m number, number
interval number
a, b, rect number, number, boolean [optional]
[P] [X] [static]
Similar to SetImageState.
name string
blend_mode string
vertex_color1 lstg::Color [optional]
vertex_color2 lstg::Color [optional]
vertex_color3 lstg::Color [optional]
vertex_color4 lstg::Color [optional]
[P] [X] [static]
Similar to SetImageCenter.
name string
x number
y number
[P] [X] [static]
Load a particle resource.
-
def_file specifies path of definition file.
-
img_name specifies name of image resource.
-
a, b, rect specifies parameters of the collision box.
Supports HGE format.
name string
def_file string
img_name string
a number [optional]
b number [optional]
rect boolean [optional]
[P] [X] [static]
Load a texture font resource.
-
def_file specifies path of definition file.
-
(P) bind_tex specifies texture path, only used by fancy2d format.
(P) Supports HGE format and fancy2d format.
(X) Supports HGE format.
For HGE format, texture file will be searched at the same directory of def_file.
name string
def_file string
bind_tex [optional] string
mipmap boolean [optional] Default is true.
[P] [X] [static]
(P) Set status of a texture font resource.
(X) Set status of a font resource.
name string
blendMode string
color lstg::Color [optional]
[P] [X] [static]
Load a TTF font resource.
-
path specifies path of font file.
-
(P) width, height specifies width and height of font.
-
(X) width specifies size of font.
name string
path string
width number
height number
[P] [X] [static]
Load a sound resource.
-
(P) Supports WAV and OGG format. WAV format is recommended.
-
(X) Supports WAV, OGG, MP3 and FLAC format. WAV format is recommended.
Sound will be loaded into memory entirely. Please avoid using big audio files.
WAV file of non-standard or compressed format is not supported.
name string
path string
[P] [X] [static]
Load a music resource.
-
loop_end, loop_duration specifies end time and length of looping in seconds. The loop range will be loop_end-loop_duration to loop_end.
-
(P) Supports WAV and OGG format. OGG format is recommended.
-
(X) Supports WAV, OGG, MP3 and FLAC format. OGG format is recommended.
Music will not be loaded into memory entirely.
The looping function is implemented by decoder so it's completely seamless.
name string
path string
loop_end number
loop_duration number
[P] [static]
Load a shader resource.
path specifies path of FX format file.
name string
path string
[X] [static]
Load a shader resource.
-
fShader specifies path or content of fragment shader. Will be default fragment shader if got nil.
-
vShader specifies path of content of vertex shader. Will be default vertex shader if got nil.
-
isString specifies if fShader and vShader is string content rather than path.
name string
fShader string [optional]
vShader string [optional]
isString boolean [optional]
[P] [X] [static]
Create a RenderTarget.
- (P) Will be treated as texture resource.
name string
[P] [X] [static] [deprecated in X]
(P) Check if a texture resource is RenderTarget.
(X) Check if a render target resource exists.
name string
-
LuaSTG uses Cartesian coordinate system as screen coordinate system, which means right and up are positive direction. The original point is the left-bottom of screen.
-
There is a global scale factor for rendering. It will affect some render functions.
-
Z-buffer will not be enabled by default.
-
All render functions must be invoked in RenderFunc (render() callback of game class).
RenderTarget cannot be rendered when under using.
[P] [X] [static]
Notice engine the beginning of rendering. Must invoked in RenderFunc.
All render functions should be invoked between BeginScene and EndScene.
[P] [X] [static]
Notice engine the ending of rendering. Must invoked in RenderFunc.
[P] [X] [static]
Clear screen with specified color. Will also clear z-buffer if enabled.
lstg::Color
[P] [X] [static]
Set viewport. Will affect clipping and rendering.
left number
right number
bottom number
top number
[P] [X] [static]
Set orthogonal projection.
(P) Z range will be [0, 1].
(X) Z range will be [-1024, 1024].
left number
right number
bottom number
top number
[P] [X] [static]
Set perspective projection.
-
(eyeX, eyeY, eyeZ) specifies eye position.
-
(atX, atY, atZ) specifies target position.
-
(upX,upY,upZ) specifies up vector.
-
fovy specifies field of view in radians.
-
aspect specifies aspect ratio.
-
zn, zf specifies z-near and z-far plane.
eyeX, eyeY, eyeZ number, number, number
atX, atY, atZ number, number, number
upX, upY, upZ number, number, number
fovy number
aspect number
zn number
zf number
[P] [X] [static]
Render an image.
-
(x, y) specifies center position.
-
rot specifies rotation in radians.
-
(hscale, vscale) specifies horizontal and verticle scale. vscale will be same as hscale if only hscale is assigned.
-
z specifies z position.
Will be affected by the global scale factor.
image_name string
x number
y number
rot number [optional] Default is 0.
hscale number [optional] Default is 1.
vscale number [optional] Default is hscale or 1.
z number= [optional] Default is 0.5.
[P] [X] [static]
Render an image in the specified rectangle. Z position will be 0.5.
image_name string
left number
right number
bottom number
top number
[P] [X] [static]
Render an image in specified vertex positions.
image_name string
x1, y1, z1 number, number,number
x2, y2, z2 number, number,number
x3, y3, z3 number, number,number
x4, y4, z4 number, number,number
[P] [X] [static]
Clear fog effect.
[P] [X] [static]
Set fog effect.
-
If near is -1, EXP1 algorism will be used and far will be density parameter.
-
If near is -2, EXP2 algorism will be used and far will be density parameter.
-
Otherwise, linear algorism will be used and near, far will be range parameter.
near number
far number
color lstg::Color [optional] Default is 0x00FFFFFF.
[P] [X] [static]
Render a texture font resource.
-
text specifies text to render.
-
(x, y) specifies position.
-
scale specifies scale.
-
align specifies alignment.
Will be affected by the global scale factor.
Values for align:
LT: 0 / MT: 1 / RT: 2
LM: 4 / MM: 5 / RM: 6
LB: 8 / MB: 9 / RB: 10
- This function is overwritten in core script and has different parameters.
name string
text string
x number
y number
scale number [optional] Default is 1.
align number [optional] Default is 5.
[P] [X] [static]
Render a texture resource.
vertex1-4 specify vertices and shoudl have following fields:
[1] = X coordinate
[2] = Y coordinate
[3] = Z coordinate
[4] = U coordinate (in pixels)
[5] = V coordinate (in pixels)
[6] = color
tex_name string
blend string
vertex1 table
vertex2 table
vertex3 table
vertex4 table
[P] [X] [static]
Render a TTF font resource.
-
name specifies name of font resource.
-
text specifies text to render.
-
left, right, bottom, top specifies a box that text will be rendered into.
-
format specifies how text is aligned in the box.
-
color specifies blend color.
-
scale specifies scale. This value will be multiplied by 0.5 in the engine.
(X) Will use values from resource if format and subsequent parameters are omitted.
Will be affected by the global scale factor.
- This function is overwritten in core script and has different parameters.
name string
text string
left number
right number
bottom number
top number
format number
color lstg::Color
scale number [optional] Default is 1.
[P] [X] [static]
Push a render target into render target stack and use it as render output.
Render targets are managed by a stack so it's possible to use them nestedly.
Usages should satisfy:
PushRenderTarget(name)
...
PopRenderTarget()
name string
[P] [X] [static]
Pop a render target from render target stack.
[P] [X] [static]
Apply post effect and render result to screen. Values in args will be passed to shader.
blend specifies how result will be rendered.
(P) Only the first 'technique' will be used in the shader.
(P) Preset values can be get by following annotations:
(X) Preset values can be get by following uniform names:
(P) POSTEFFECTTEXTURE: texture to apply effect (texture2d)
(X) u_texture: texture to apply effect (sampler2D)
VIEWPORT: size of viewport (float4)
SCREENSIZE: size of screen (float4)
name string
fx_name string
blend string
args table [optional]
[P] [X] [static] [deprecated in X]
A shortcut to begin post effect.
Equivalent to:
PushRenderTarget(InternalRenderTarget)
[P] [X] [static] [deprecated in X]
A shortcut to finish post effect. An internal render target is used.
Equivalent to:
PopRenderTarget(InternalRenderTarget)
PostEffect(InternalRenderTarget, fx_name, blend, args) Usages should satisfy:
PostEffectCapture()
...
PostEffectApply(...)
fx_name string
blend string
args table [optional]
[P] [X] [static]
Play a sound resource.
-
vol specifies volume, the range is [0, 1].
-
pan specifies channel balance, the range is [-1, 1].
A sound will be interrupted if it's played again.
name string
vol number
pan number [optional] Default is 0.
[P] [X] [static]
Stop a sound resource.
name string
[P] [X] [static]
Pause a sound resource.
name string
[P] [X] [static]
Resume a sound resource.
name string
[P] [X] [static]
Returns status of a sound resource. Will return "paused", "playing" or "stopped".
name string
string
[P] [X] [static]
Play a music resource.
-
vol specifies volume, the range is [0, 1].
-
position specifies start position in seconds.
name string
vol number [optional] Default is 1.
position number [optional] Default is 0.
[P] [X] [static]
Stop a music resource. Will set playback position to the beginning.
name string
[P] [X] [static]
Pause a music resource.
name string
[P] [X] [static]
Resume a music resource.
name string
[P] [X] [static]
Returns status of a music resource. Will return "paused", "playing" or "stopped".
name string
string
[P] [X] [static]
Set global volume factor for sound resources. The value will be multiplied to vol parameter of PlaySound. Will not affect playing sounds.
- (P) vol should in range [0, 1].
vol number
[X] [static]
Set volume of specified sound. Will affect playing sounds.
- vol should in range [0, 1].
name string
vol number
[P] [X] [static]
Set global volume factor for music resources. The value will be multiplied to vol parameter of PlayMusic. Will not affect playing musics.
- (P) vol should in range [0, 1].
vol number
[P] [X] [static]
Set volume of specified sound. Will affect playing musics.
- vol should in range [0, 1].
name string
vol number
(P) Gamepad input is mapped to code 0x92 - 0xB1.
(X) Gamepad input is mapped dynamically to existing codes.
[P] [X] [static]
Check if key corresponding to code is pressed.
- (P) code is VK_CODE defined by microsoft.
- (X) code is EventKeyboard::KeyCode defined by cocos.
code number
boolean
[P] [X] [static]
Returns code of last pressed key.
number
[P] [X] [static] [deprecated in X]
- (P) Returns last input char.
- (X) Do nothing.
string
[P] [X] [static]
(P) Get mouse position in pixels starts from the bottom left of the window.
(X) Get mouse position in screen coordinates starts from the bottom left of the window.
number,number
[P] [X] [static]
Check if mouse button is pressed.
- button specifies button to check. 0/1/2 correspond to left/middle/right.
button number
boolean
[P] [X] [static]
Take a snapshot of screen and save to file_path in PNG format.
file_path string
[P] [static]
Execute an external program at path.
Returns true on success, false on failure.
path string
arguments string [optional]
directory string [optional]
wait boolean [optional] Default is true.
boolean
The following trigonometric functions accept degree values.
[P] [X] [static]
ang
[P] [X] [static]
ang
[P] [X] [static]
v
[P] [X] [static]
v
[P] [X] [static]
ang
[P] [X] [static]
v
[P] [X] [static]
y,x
[P] [X] [static]
Create a RNG object.
RNG
[P] [X] [static]
Create a Color object.
argb number
lstg::Color
[P] [X] [static]
Create a Color object.
a number
r number
g number
b number
lstg::Color
[P] [X] [static]
Create a BentLaserData object.
BentLaserData
[P] [X] [static]
Returns the table where game objects are stored.
table
Following functions should be defined in global namespace and will be invoked by the engine. They are already defined in the core script.
[P] [X] [static]
Will be invoked after the initialization of engine finished.
[P] [X] [static]
Will be invoked when the window lose focus.
[P] [X] [static]
Will be invoked when the window get focus.
[P] [X] [static]
Will be invoked every frame to process all frame logic.
Game will exit if it returns true.
boolean
[P] [X] [static]
Will be invoked every frame to process all render instructions.
lstg::Color (Color for short) class is used to represent a 32-bit color. The a/r/g/b component represents alpha/red/green/blue value.
- Color object can be constructed by Color().
- Components a, r, g, b are in range [0, 255].
- Components will be clamped to [0, 255] when performing arithmetic operation if not specified.
- (X) Components can be accessed and assigned by field a, r, g, b.
- (X) 32-bit value can be accessed and assigned by field argb.
- (X) Other methods and custom constructor are extended in Lua scripts. Please refer to the document or source code of LuaSTG-x.
- A Color object is a Lua userdata.
[P] [X]
Returns a, r, g, b components respectively.
number, number, number, number
[X]
Returns r, g, b, a components respectively.
number, number, number, number
[X]
Returns r, g, b, a components scaled to [0, 1] respectively.
number, number, number, number
[X]
Set values of components. Alpha component is optional. Returns self.
R number
G number
B number
A number [optional]
Color
[X]
Set values of components in range [0, 1]. Alpha component is optional. Returns self.
R number
G number
B number
A number [optional]
Color
[P] [X] [static]
Returns a clone of the color.
Color
[P] [X] [static]
Returns whether two color values are equal.
lhs Color
rhs Color
boolean
[P] [X] [static]
Add two color values component-wise.
lhs Color
rhs Color
Color
[P] [X] [static]
Subtract two color values component-wise.
lhs Color
rhs Color
Color
[P] [X] [static]
When passed with two Color objects:
Multiply two color values component-wise as if components are in range [0, 1].
When passed with a Color object and a number:
Multiply components with a number.
lhs Color/number
rhs Color/number
Color
[P] [X] [static]
Returns decription of the color value.
self Color
string
RNG (random number generator) class is used for generating pseudo random number.
- RNG object can be constructed by Rend().
- RNG class uses WELL512 algorithm.
Default global RNG object is implemented by lstg::Random class in LuaSTG-x and has other methods. Please refer to the document or source code of LuaSTG-x.
[P] [X]
Set seed. seed shoule in range [0, 2^32-1].
seed number
[P] [X]
Returns the seed.
number
[P] [X]
Returns a random integer in range [min, max]. min should not be bigger than max.
min number
max number
number
[P] [X]
Returns a random float in range [min, max]. min should not be bigger than max.
min number
max number
number
[P] [X]
Returns 1 or -1 randomly.
number
BentLaserData class is used to control bent laser (aka curvy laser) function provided by the engine.
For the sake of brevity, we call the first node of bent laser "head", the last node "tail".
- BentLaserData object can be constructed by BentLaserData().
- (P) There are 1024 bent lasers at most.
- Bent laser is composed by nodes.
- Each bent laser can have 512 nodes at most. You can limit it to a smaller number for each one.
- (P) A new node can only be added as head.
- (X) A new node can only be added as head or tail.
- When node count exceeds limit as you add a node in one side, the node on the other side will be deleted.
- (P) Properties of a node: position, width.
- (X) Properties of a node: position, width, color.
- (P) Property of a node can not be changed once it's added.
BentLaserData is implemented by lstg::GameObjectBentLaser class in LuaSTG-x and has different methods. Please refer to the document or source code of LuaSTG-x.
[P]
Add a new node to bent laser. Its position will be (obj.x, obj.y).
-
length specifies the limit of node count.
-
width specifies the width property of node.
obj object
length number
width number
[P]
Legacy of old version. Do nothing.
[P]
Render bent laser.
-
texName specifies name of texture resource.
-
blend specifies name of blend mode.
-
color specifies color property of all vertices.
-
texLeft, texTop, texWidth, texHeight specifies texture coordinates in range [0, 1].
-
scale specifies the scale apply to each node's width.
Will be affected by the global scale factor.
texName string
blend string
color lstg::Color
texLeft number
texTop number
texWidth number
texHeight number
scale number
[P]
Do collision check with a fake object as if it has given properties.
Returns true is there is collision.
Each node will be treated as a circle whose radius is half of the width.
x number
y number
rot number [optional] Default is 0.
a number [optional] Default is 0.
b number [optional] Default is 0.
rect boolean [optional] Default is false.
boolean
[P]
Check if all nodes' position are in the range set by SetBound().
boolean