API Manual
Introduction[edit | edit source]
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.LuaSTGPlus的原始API手册见此处。
LuaSTG-x的完整API文档见此处。由于新增了大量函数,推荐LuaSTG-x用户使用该文档。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.
Legend 图例 Legend
| |
---|---|
[P] | This API is avalible in LuaSTGPlus. 该API仅适用于LuaSTGPlus This API is avalible in LuaSTGPlus.
|
[P_Ex] | This API is only avalible in LuaSTG ExPlus. 该API仅适用于LuaSTGExPlus This API is only avalible in LuaSTG ExPlus.
|
[X] | This API is avalible in LuaSTG-x. 该API仅适用于LuaSTG-x This API is avalible in LuaSTG-x.
|
[static] | This API is a static function. 该API为静态函数 This API is a static function.
|
(P) | Following descriptions only apply for LuaSTGPlus. 该描述仅适用于LuaSTGPlus Following descriptions only apply for LuaSTGPlus.
|
(X) | Following descriptions only apply for LuaSTG-x. 该描述仅适用于LuaSTG-x Following descriptions only apply for LuaSTG-x.
|
(P_Ex) | Following descriptions only apply for LuaSTG ExPlus. 该描述仅适用于LuaSTGPlus Following descriptions only apply for LuaSTG ExPlus.
|
Global Variables[edit | edit source]
lstg[edit | edit source]
[P] [X]
- Type
- table
args[edit | edit source]
[P]
- Type
- table
_ARGS[edit | edit source]
[X]
- Type
- table
Frame Control[edit | edit source]
SetWindowed(isWindowed)
[P] [X] [static] [deprecated in X]
- (P) Can only be invoked during launch instead of runtime.
- (P) 仅限初始化时使用,无法在运行时使用。
- (P) Can only be invoked during launch instead of runtime.
Parameters参数パラメータ
isWindowed boolean
SetFPS(targetFPS)
[P] [X] [static]
- (P) Can only be invoked during launch instead of runtime.
- (P) 仅限初始化时使用,无法在运行时使用。
- (P) Can only be invoked during launch instead of runtime.
Parameters参数パラメータ
targetFPS number
GetFPS()
[P] [X] [static]
Return value返回值戻り値
- number
SetVsync(isEnable)
[P] [X] [static]
- (P) Can only be invoked during launch instead of runtime.
- (P) 仅限初始化时使用,无法在运行时使用。
- (P) Can only be invoked during launch instead of runtime.
Parameters参数パラメータ
isEnable boolean
SetResolution(width, height)
[P] [X] [static]
- (P) Can only be invoked during launch instead of runtime.
- (P) 仅限初始化时使用,无法在运行时使用。
- (P) Can only be invoked during launch instead of runtime.
Parameters参数パラメータ
width number height number
ChangeVideoMode(width, height, windowed, vsync)
[P] [X] [static]
- (P) Can only be invoked during runtime.
- (P) 仅限运行时使用。
- (P) Can only be invoked during runtime.
Parameters参数パラメータ
width number height number windowed boolean vsync boolean
Return value返回值戻り値
- boolean
SetSplash(boolean)
[P] [X] [static]
- (P) Default is false.
- (X) Default is true.
- (P) 默认为 false.
- (X) 默认为 true.
- (P) Default is false.
- (X) Default is true.
Parameters参数パラメータ
boolean
SetTitle(title)
[P] [X] [static]
- (P) Default is "LuaSTGPlus".
- (X) Default is "LuaSTG-x".
- (P) 默认为 "LuaSTGPlus".
- (X) 默认为 "LuaSTG-x".
- (P) Default is "LuaSTGPlus".
- (X) Default is "LuaSTG-x".
Parameters参数パラメータ
title string
SystemLog(str)
[P] [X] [static]
Parameters参数パラメータ
str string
Print(...)
[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) 在桌面平台上将多个值打印至console。在移动平台上将多个值写入日志文件。
- (P) Write values to log file.
- (X) Print values to console on desktop platforms. Write values to log file on mobile platforms.
Parameters参数パラメータ
...
LoadPack(path, password)
[P] [X] [static]
Will throw an error if failed.
- Detail
- 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.
失败时将抛出错误。
- 细节
- 后加载的资源包有较高的查找优先级。这意味着可以覆盖之前包中的文件。
- zip文件在加载后将被程序占用。
- 加载文件时将按照优先级依次搜索,若资源包中未找到则从本地路径加载。
Will throw an error if failed.
- Detail
- 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.
Parameters参数パラメータ
path string password string [optional]
UnloadPack(path)
[P] [X] [static]
Parameters参数パラメータ
path string
ExtractRes(path, target)
[P] [X] [static]
Parameters参数パラメータ
path string target string
DoFile(path)
[P] [X] [static]
Parameters参数パラメータ
path string
ShowSplashWindow(path)
[P] [X] [static] [deprecated in X]
- (P) Set the loading picture.
- Will use default picture if failed or path not passed.
- (X) Do nothing.
- (P) 设置启动图片。
- 若图片加载失败或为空则使用默认图片。
- (X) 无作用。
- (P) Set the loading picture.
- Will use default picture if failed or path not passed.
- (X) Do nothing.
Parameters参数パラメータ
path string [optional] Path of picture file.
Game Object Pool[edit | edit source]
GetnObj()
[P] [X] [static]
Return value返回值戻り値
- number
ObjFrame()
[P] [X] [static]
Do not invoke in coroutine.
- Detail
- Properties will be updated in the following order:
- vx += ax
- vy += ay
- x += vx
- y += vy
- rot += omiga
- Update paritle system if there is
禁止在协程上调用该方法。
- 细节
- 属性将按以下顺序更新:
- vx += ax
- vy += ay
- x += vx
- y += vy
- rot += omiga
- 更新粒子系统(若有)
Do not invoke in coroutine.
- Detail
- Properties will be updated in the following order:
- vx += ax
- vy += ay
- x += vx
- y += vy
- rot += omiga
- Update paritle system if there is
ObjRender()
[P] [X] [static]
Object with smaller layer property will be rendered first.
Do not invoke in coroutine.具有较小 layer 属性的游戏对象将会先渲染。
禁止在协程上调用该方法。Object with smaller layer property will be rendered first.
Do not invoke in coroutine.SetBound(left, right, bottom, top)
[P] [X] [static]
Parameters参数パラメータ
left number right number bottom number top number
BoundCheck()
[P] [X] [static]
An object will not be marked if bound property is false.
Do not invoke in coroutine.当游戏对象的 bound 属性为 false 时将不会被标记。
禁止在协程上调用该方法。An object will not be marked if bound property is false.
Do not invoke in coroutine.CollisionCheck(A, B)
[P] [X] [static]
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.
若 A(组中的)对象和 B(组中的)对象发生碰撞,前者的 colli() 回调将会被调用,后者会作为参数传入。
- (P) A 和 B 为碰撞组ID。
- (X) A 和 B 为碰撞组ID或游戏对象。
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.
Parameters参数パラメータ
A number/object B number/object
UpdateXY()
[P] [X] [static]
AfterFrame()
[P] [X] [static]
Do not invoke in coroutine.
- Detail
- Set status property of an object to "normal" to preserve it.
禁止在协程上调用该方法。
- 细节
- 将游戏对象的 status 属性设置为 "normal" 可以将其保留。
Do not invoke in coroutine.
- Detail
- Set status property of an object to "normal" to preserve it.
New(class)
[P] [X] [static]
- Detail
- Game object is created based on class and will invoke init() callback.
- Created object will have following properties:
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 for render class class of the object a, b parameters of collision box size 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 创建并将调用 init() 回调。
- 被创建的对象具有如下属性:
x, y 坐标 dx, dy 坐标相对于上次更新时的增量(只读) rot 朝向(角度) omiga 朝向的角速度 timer 更新计数器 vx, vy 速度 ax, ay 加速度 layer 渲染层级 group 碰撞组 hide 是否隐藏(跳过渲染回调) bound 是否越界销毁 navi 是否根据速度自动更新朝向 colli 是否参与碰撞检测 status 对象状态,取值为 "del", "kill" 或 "normal" hscale, vscale 横向、纵向的渲染缩放 class 对象的类 a, b 碰撞盒尺寸的参数 rect 是否为矩形碰撞盒 img 绑定的可渲染资源的名字 ani 动画计数器(只读)
- 游戏对象的索引 1 和 2 用于保存 class 和内部ID,请勿修改。
- class 需要具有以下属性:
- 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
- 回调函数将在对象触发相应事件时被调用。
- 游戏对象数量的上限为32768。超出后将抛出错误。
- Detail
- Game object is created based on class and will invoke init() callback.
- Created object will have following properties:
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 for render class class of the object a, b parameters of collision box size 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.
Parameters参数パラメータ
class table
Del(object, ...)
[P] [X] [static]
Parameters参数パラメータ
object ... [optional]
Kill(object, ...)
[P] [X] [static]
Parameters参数パラメータ
object ... [optional]
IsValid(object)
[P] [X] [static]
Parameters参数パラメータ
object
GetV(object)
[P] [X] [static]
Parameters参数パラメータ
object
Return value返回值戻り値
- number,number
SetV(object, magnitude, direction, updateRot)
[P] [X] [static]
Parameters参数パラメータ
object object magnitude number direction number updateRot boolean
SetImgState(object, blend, a, r, g, b)
[P] [X] [static]
Parameters参数パラメータ
object blend string a number r number g number b number
Angle(a, b)
[P] [X] [static]
Parameters参数パラメータ
a object b object
Return value返回值戻り値
- number
Angle(x1, y1, x2, y2)
[P] [X] [static]
Parameters参数パラメータ
x1 number y1 number x2 number y2 number
Return value返回值戻り値
- number
Dist(a, b)
[P] [X] [static]
Parameters参数パラメータ
a object b object
Return value返回值戻り値
- number
Dist(x1, y1, x2, y2)
[P] [X] [static]
Parameters参数パラメータ
x1 number y1 number x2 number y2 number
Return value返回值戻り値
- number
BoxCheck(object, left, right, top, bottom)
[P] [X] [static]
Parameters参数パラメータ
object left number right number top number bottom number
Return value返回值戻り値
- boolean
ResetPool()
[P] [X] [static]
DefaultRenderFunc(object)
[P] [X] [static]
Parameters参数パラメータ
object
NextObject(groupid, id)
[P] [X] [static]
Parameters参数パラメータ
groupid number id number
Return value返回值戻り値
- number,object
ObjList(groupid)
[P] [X] [static]
- Example
- for _, obj in ObjList(GROUP_ITEM) do ... end
- 示例
- for _, obj in ObjList(GROUP_ITEM) do ... end
- Example
- for _, obj in ObjList(GROUP_ITEM) do ... end
Parameters参数パラメータ
groupid number
Return value返回值戻り値
- function
ParticleFire(object)
[P] [X] [static]
Parameters参数パラメータ
object
ParticleStop(object)
[P] [X] [static]
Parameters参数パラメータ
object
ParticleGetn(object)
[P] [X] [static]
Parameters参数パラメータ
object
Return value返回值戻り値
- number
ParticleGetEmission(object)
[P] [X] [static]
- Detail
- Particle emitter will always step by 1/60 seconds.
- 细节
- 粒子发射器始终以1/60秒的步进更新。
- Detail
- Particle emitter will always step by 1/60 seconds.
Parameters参数パラメータ
object
ParticleSetEmission(object, count)
[P] [X] [static]
Parameters参数パラメータ
object count
Game Resource[edit | edit source]
RemoveResource(poolType)
[P] [X] [static]
Parameters参数パラメータ
poolType string
RemoveResource(poolType, resType, name)
[P] [X] [static]
Parameters参数パラメータ
poolType string resType number Resource type code name string
CheckRes(type, name)
[P] [X] [static]
- Detail
- Will search in global pool at first, then stage pool.
- Returns nil if resource not exists.
- 细节
- 先在 global 池中查找,然后是 stage 池。
- 若资源不存在则返回 nil。
- Detail
- Will search in global pool at first, then stage pool.
- Returns nil if resource not exists.
Parameters参数パラメータ
type number name string
Return value返回值戻り値
- string
EnumRes(type)
[P] [X] [static]
Parameters参数パラメータ
type number Resource type code
Return value返回值戻り値
- table, table
GetTextureSize(name)
[P] [X] [static]
Parameters参数パラメータ
name string
Return value返回值戻り値
- number, number
LoadTexture(name, path, mipmap)
[P] [X] [static]
Parameters参数パラメータ
name string path string mipmap boolean [optional] Default is false
LoadImage(name, tex_name, x, y, w, h, a, b, rect)
[P] [X] [static]
- 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.
- Detail
- When a image resource is assigned to img property of an object, collision box parameters will be assigned to the object.
- x, y 指定图像在纹理坐标的左上角位置(像素)。
- w, h 指定图像的宽度和高度(像素)。
- a, b, rect 指定碰撞盒参数。
- 细节
- 当图像资源被赋予游戏对象的 img 属性时,碰撞盒参数参数会同时赋予该对象。
- 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.
- Detail
- When a image resource is assigned to img property of an object, collision box parameters will be assigned to the object.
Parameters参数パラメータ
name string tex_name string x number y number w number h number a number [optional] b number [optional] rect boolean [optional]
SetImageState(name, blendMode, vertColor1, vertColor2, vertColor3, vertColor4)
[P] [X] [static]
Parameters参数パラメータ
name string blendMode string vertColor1 lstg::Color [optional] vertColor2 lstg::Color [optional] vertColor3 lstg::Color [optional] vertColor4 lstg::Color [optional]
SetImageCenter(name, x, y)
[P] [X] [static]
Parameters参数パラメータ
name string x number y number
LoadAnimation(name, tex_name, x, y, w, h, n, m, interval, a, b, rect)
[P] [X] [static]
- 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.
- x, y 指定第一帧的左上角坐标。
- w, h 指定每帧的宽度和高度。
- n, m 指定列和行的数量。
- interval 指定播放间隔,单位为帧。
- a, b, rect 指定碰撞盒参数。
- 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.
Parameters参数パラメータ
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]
SetAnimationState(name, blend_mode, vertColor1, vertColor2, vertColor3, vertColor4)
[P] [X] [static]
Parameters参数パラメータ
name string blend_mode string vertColor1 lstg::Color [optional] vertColor2 lstg::Color [optional] vertColor3 lstg::Color [optional] vertColor4 lstg::Color [optional]
SetAnimationCenter(name, x, y)
[P] [X] [static]
Parameters参数パラメータ
name string x number y number
LoadPS(name, def_file, img_name, a, b, rect)
[P] [X] [static]
- def_file specifies path of definition file.
- img_name specifies name of image resource.
- a, b, rect specifies parameters of the collision box.
- def_file 指定定义文件的路径。
- img_name 指定图像资源的名称。
- a, b, rect 指定碰撞盒参数。
- def_file specifies path of definition file.
- img_name specifies name of image resource.
- a, b, rect specifies parameters of the collision box.
Parameters参数パラメータ
name string def_file string img_name string a number [optional] b number [optional] rect boolean [optional]
LoadFont(name, def_file, bind_tex [optional], mipmap)
[P] [X] [static]
- def_file specifies path of definition file.
- (P) bind_tex specifies texture path, only used by fancy2d format.
- Detail
- (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.
- def_file 指定定义文件的路径。
- (P) bind_tex 指定纹理路径,仅用于 fancy2d 格式。
- Detail
- (P) 支持 HGE 格式和 fancy2d 格式。
- (X) 支持 HGE 格式。
- 对于 HGE 格式,纹理文件将在 def_file 的同级路径查找。
- def_file specifies path of definition file.
- (P) bind_tex specifies texture path, only used by fancy2d format.
- Detail
- (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.
Parameters参数パラメータ
name string def_file string bind_tex [optional] string mipmap boolean [optional] Default is true.
SetFontState(name, blendMode, color)
[P] [X] [static]
Parameters参数パラメータ
name string blendMode string color lstg::Color [optional]
LoadTTF(name, path, width, height)
[P] [X] [static]
- path specifies path of font file.
- (P) width, height specifies width and height of font.
- (X) width specifies size of font.
- path 指定字体文件的路径。
- (P) width, height 指定字体的宽度和高度。
- (X) width 指定字体的大小。
- path specifies path of font file.
- (P) width, height specifies width and height of font.
- (X) width specifies size of font.
Parameters参数パラメータ
name string path string width number height number
LoadSound(name, path)
[P] [X] [static]
- (P) Supports WAV and OGG format. WAV format is recommended.
- (X) Supports WAV, OGG, MP3 and FLAC format. WAV format is recommended.
- Detail
- Sound resource will be loaded into memory entirely. Please avoid using big audio files.
- WAV file of non-standard or compressed format is not supported.
- (P) 支持 WAV 和 OGG 格式。推荐 WAV 格式。
- (X) 支持 WAV, OGG, MP3 和 FLAC 格式。推荐 WAV 格式。
- 细节
- 音效资源将被整体加载进内存。请勿使用较大的音频文件。
- 不支持非标准的或压缩格式的 WAV 文件。
- (P) Supports WAV and OGG format. WAV format is recommended.
- (X) Supports WAV, OGG, MP3 and FLAC format. WAV format is recommended.
- Detail
- Sound resource will be loaded into memory entirely. Please avoid using big audio files.
- WAV file of non-standard or compressed format is not supported.
Parameters参数パラメータ
name string path string
LoadMusic(name, path, loop_end, loop_duration)
[P] [X] [static]
- loop_end, loop_duration specifies end time and length of repeat section in seconds. The repeat 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.
- Detail
- Music resource will not be loaded into memory entirely.
- The repeat function is implemented by decoder so it's completely seamless.
- loop_end, loop_duration 指定循环节的结束和时长,单位为秒。循环范围为 loop_end-loop_duration 至 loop_end。
- (P) 支持 WAV 和 OGG 格式。推荐 OGG 格式。
- (X) 支持 WAV, OGG, MP3 和 FLAC 格式。推荐 OGG 格式。
- 细节
- 音乐资源不会被整体加载进内存。
- 循环功能由解码器实现,因此是无缝的。
- loop_end, loop_duration specifies end time and length of repeat section in seconds. The repeat 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.
- Detail
- Music resource will not be loaded into memory entirely.
- The repeat function is implemented by decoder so it's completely seamless.
Parameters参数パラメータ
name string path string loop_end number loop_duration number
LoadFX(name, path)
[P] [static]
Parameters参数パラメータ
name string path string
LoadFX(name, fShader, vShader, isString)
[X] [static]
- 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.
- fShader 指定像素着色器的路径或内容。传入 nil 时将使用默认像素着色器。
- vShader 指定顶点着色器的路径或内容。传入 nil 时将使用默认顶点着色器。
- isString 指定 fShader 和 vShader 是字符串内容还是路径。
- 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.
Parameters参数パラメータ
name string fShader string [optional] vShader string [optional] isString boolean [optional]
CreateRenderTarget(name)
[P] [X] [static]
- (P) Will be treated as a texture resource.
- (P) 将作为纹理资源使用。
- (P) Will be treated as a texture resource.
Parameters参数パラメータ
name string
IsRenderTarget(name)
[P] [X] [static] [deprecated in X]
Parameters参数パラメータ
name string
Render[edit | edit source]
- The engine 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).
- A render target cannot be rendered when under using.
- 引擎使用笛卡尔坐标系作为窗口坐标系,右和上为正方向,原点为屏幕左下角。
- 引擎提供一个全局渲染缩放系数,会影响一些渲染函数。
- 引擎默认关闭深度缓冲。
- 所有渲染函数必须在 RenderFunc(render() 回调)中调用。
- 渲染目标在使用中不能被渲染。
- The engine 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).
- A render target cannot be rendered when under using.
BeginScene()
[P] [X] [static]
EndScene()
[P] [X] [static]
RenderClear(lstg::Color)
[P] [X] [static]
Parameters参数パラメータ
lstg::Color
SetViewport(left, right, bottom, top)
[P] [X] [static]
Parameters参数パラメータ
left number right number bottom number top number
SetOrtho(left, right, bottom, top)
[P] [X] [static]
- Detail
- (P) Z range will be [0, 1].
- (X) Z range will be [-1024, 1024].
- 细节
- (P) Z 范围为 [0, 1]。
- (X) Z 范围为 [-1024, 1024]。
- Detail
- (P) Z range will be [0, 1].
- (X) Z range will be [-1024, 1024].
Parameters参数パラメータ
left number right number bottom number top number
SetPerspective(eyeX, eyeY, eyeZ, atX, atY, atZ, upX, upY, upZ, fovy, aspect, zn, zf)
[P] [X] [static]
- (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) 指定观察者位置。
- (atX, atY, atZ) 指定观察目标位置。
- (upX,upY,upZ) 指定观察者的上方向。
- fovy 指定视角范围(弧度)
- aspect 指定宽高比。
- zn, zf 指定Z轴近平面和远平面。
- (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.
Parameters参数パラメータ
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
Render(image_name, x, y, rot, hscale, vscale, z)
[P] [X] [static]
- (x, y) specifies position of image center.
- rot specifies rotation in radians. Default is 0.
- (hscale, vscale) specifies horizontal and verticle scale. Default of hscale is 1. vscale will be same as hscale if only hscale is assigned.
- z specifies z coordinate. Default is 0.5.
- (x, y) 指定图像中心的位置。
- rot 指定旋转,单位为弧度。默认为 0。
- (hscale, vscale) 指定水平和垂直方向的缩放。若只指定了 hscale,vscale 将与 hscale 相同。
- z 指定Z坐标。默认为 0.5。
- (x, y) specifies position of image center.
- rot specifies rotation in radians. Default is 0.
- (hscale, vscale) specifies horizontal and verticle scale. Default of hscale is 1. vscale will be same as hscale if only hscale is assigned.
- z specifies z coordinate. Default is 0.5.
Parameters参数パラメータ
image_name string x number y number rot number [optional] hscale number [optional] vscale number [optional] z number [optional]
RenderRect(image_name, left, right, bottom, top)
[P] [X] [static]
Parameters参数パラメータ
image_name string left number right number bottom number top number
Render4V(image_name, x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4)
[P] [X] [static]
Parameters参数パラメータ
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
SetFog()
[P] [X] [static]
SetFog(near, far, color)
[P] [X] [static]
- 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 为 -1,将使用 EXP1 算法且 far 为强度参数。
- 若 near 为 -2,将使用 EXP2 算法且 far 为强度参数。
- 否则,将使用线性算法且 near, far 为范围参数。
- 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.
Parameters参数パラメータ
near number far number color lstg::Color [optional] Default is 0x00FFFFFF.
RenderText(name, text, x, y, scale, align)
[P] [X] [static]
- text specifies text to render.
- (x, y) specifies position.
- scale specifies scale. Default is 1.
- align specifies alignment. Default is 5.
Will be affected by the global scale factor.
- Detail
- 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.
- text 指定要渲染的文字。
- (x, y) 指定位置。
- scale 指定缩放。默认为 1。
- align 指定对齐模式。默认为 5。
受全局缩放系数影响。
- 细节
- align 可取值:
- 左上: 0 / 中上: 1 / 右上: 2
- 左中: 4 / 中中: 5 / 右中: 6
- 左下: 8 / 中下: 9 / 右下: 10
- 该函数已在核心脚本中被覆盖并具有不同的参数。
- text specifies text to render.
- (x, y) specifies position.
- scale specifies scale. Default is 1.
- align specifies alignment. Default is 5.
Will be affected by the global scale factor.
- Detail
- 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.
Parameters参数パラメータ
name string text string x number y number scale number [optional] align number [optional]
RenderTexture(tex_name, blend, vertex1, vertex2, vertex3, vertex4)
[P] [X] [static]
- Detail
- vertex1-4 specify vertices and should have following fields:
- [1] = X coordinate
- [2] = Y coordinate
- [3] = Z coordinate
- [4] = U coordinate (in pixels)
- [5] = V coordinate (in pixels)
- [6] = color
- 细节
- vertex1-4 指定各个顶点,需包含以下成员:
- [1] = X 坐标
- [2] = Y 坐标
- [3] = Z 坐标
- [4] = U 坐标(像素)
- [5] = V 坐标(像素)
- [6] = 颜色
- Detail
- vertex1-4 specify vertices and should have following fields:
- [1] = X coordinate
- [2] = Y coordinate
- [3] = Z coordinate
- [4] = U coordinate (in pixels)
- [5] = V coordinate (in pixels)
- [6] = color
Parameters参数パラメータ
tex_name string blend string vertex1 table vertex2 table vertex3 table vertex4 table
RenderTTF(name, text, left, right, bottom, top, format, color, scale)
[P] [X] [static]
- 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. Default is 1.
(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 指定字体资源的名称。
- text 指定要渲染的文本。
- left, right, bottom, top 指定文本要被渲染到的矩形。
- format 指定文本如何在矩形内对齐。
- color 指定混合颜色。
- scale 指定缩放。该值将在引擎内部乘以0.5。默认为 1。
(X) 若省略 format 以及之后的参数,将使用资源的参数。
受全局缩放系数影响。
- 该函数已在核心脚本中被覆盖并具有不同的参数。
- 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. Default is 1.
(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.
Parameters参数パラメータ
name string text string left number right number bottom number top number format number color lstg::Color scale number [optional]
Post Effect[edit | edit source]
PushRenderTarget(name)
[P] [X] [static]
- Detail
- Render targets are managed by a stack so it's possible to use them nestedly.
Usages should satisfy:
- PushRenderTarget(name)
- ...
- PopRenderTarget()
- 细节
- 渲染目标由一个堆栈进行管理,可以嵌套使用。
使用时需满足:
- PushRenderTarget(name)
- ...
- PopRenderTarget()
- Detail
- Render targets are managed by a stack so it's possible to use them nestedly.
Usages should satisfy:
- PushRenderTarget(name)
- ...
- PopRenderTarget()
Parameters参数パラメータ
name string
PopRenderTarget()
[P] [X] [static]
PostEffect(name, fx_name, blend, args)
[P] [X] [static]
blend specifies blend mode used for result rendering.
- Detail
- (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 uniforms:
- (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)
blend 指定渲染结果使用的渲染模式。
- 细节
- (P) 只有着色器中的第一个 technique 会被使用。
- (P) 预设值可以通过以下 annotations 取得:
- (X) 预设值可以通过以下 uniform 取得:
- (P) POSTEFFECTTEXTURE: 要应用效果的纹理 (texture2d)
- (X) u_texture: 要应用效果的纹理 (sampler2D)
- VIEWPORT: 视口大小 (float4)
- SCREENSIZE: 屏幕大小 (float4)
blend specifies blend mode used for result rendering.
- Detail
- (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 uniforms:
- (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)
Parameters参数パラメータ
name string fx_name string blend string args table [optional]
PostEffectCapture()
[P] [X] [static] [deprecated in X]
Equivalent to:
- PushRenderTarget(InternalRenderTarget)
等价于:
- PushRenderTarget(InternalRenderTarget)
Equivalent to:
- PushRenderTarget(InternalRenderTarget)
PostEffectApply(fx_name, blend, args)
[P] [X] [static] [deprecated in X]
Equivalent to:
- PopRenderTarget(InternalRenderTarget)
- PostEffect(InternalRenderTarget, fx_name, blend, args)
Usages should satisfy:
- PostEffectCapture()
- ...
- PostEffectApply(...)
等价于:
- PopRenderTarget(InternalRenderTarget)
- PostEffect(InternalRenderTarget, fx_name, blend, args)
使用时需满足:
- PostEffectCapture()
- ...
- PostEffectApply(...)
Equivalent to:
- PopRenderTarget(InternalRenderTarget)
- PostEffect(InternalRenderTarget, fx_name, blend, args)
Usages should satisfy:
- PostEffectCapture()
- ...
- PostEffectApply(...)
Parameters参数パラメータ
fx_name string blend string args table [optional]
Sound[edit | edit source]
PlaySound(name, vol, pan)
[P] [X] [static]
- vol specifies volume, the range is [0, 1].
- pan specifies channel balance, the range is [-1, 1]. Default is 0.
- Detail
- A sound resource will be interrupted if it's played again.
- vol 指定音量,范围为 [0, 1]。
- pan 指定通道平衡,范围为 [-1, 1]。 默认为 0。
- 细节
- 音效资源重复播放时会被中断。
- vol specifies volume, the range is [0, 1].
- pan specifies channel balance, the range is [-1, 1]. Default is 0.
- Detail
- A sound resource will be interrupted if it's played again.
Parameters参数パラメータ
name string vol number pan number [optional]
StopSound(name)
[P] [X] [static]
Parameters参数パラメータ
name string
PauseSound(name)
[P] [X] [static]
Parameters参数パラメータ
name string
ResumeSound(name)
[P] [X] [static]
Parameters参数パラメータ
name string
GetSoundState(name)
[P] [X] [static]
Parameters参数パラメータ
name string
Return value返回值戻り値
- string
PlayMusic(name, vol, position)
[P] [X] [static]
- vol specifies volume, the range is [0, 1]. Default is 1.
- position specifies start position in seconds. Default is 0.
- vol 指定音量,范围为 [0, 1]。默认为 1.
- position 指定播放的起始位置,单位为秒。默认为 0.
- vol specifies volume, the range is [0, 1]. Default is 1.
- position specifies start position in seconds. Default is 0.
Parameters参数パラメータ
name string vol number [optional] position number [optional]
StopMusic(name)
[P] [X] [static]
Parameters参数パラメータ
name string
PauseMusic(name)
[P] [X] [static]
Parameters参数パラメータ
name string
ResumeMusic(name)
[P] [X] [static]
Parameters参数パラメータ
name string
GetMusicState(name)
[P] [X] [static]
Parameters参数パラメータ
name string
Return value返回值戻り値
- string
SetSEVolume(vol)
[P] [X] [static]
- (P) vol should in range [0, 1].
- (P) vol 范围为 [0, 1]。
- (P) vol should in range [0, 1].
Parameters参数パラメータ
vol number
SetSEVolume(name, vol)
[X] [static]
- vol should in range [0, 1].
- vol 范围为 [0, 1]。
- vol should in range [0, 1].
Parameters参数パラメータ
name string vol number
SetBGMVolume(vol)
[P] [X] [static]
- (P) vol should in range [0, 1].
- (P) vol 范围为 [0, 1]。
- (P) vol should in range [0, 1].
Parameters参数パラメータ
vol number
SetBGMVolume(name, vol)
[P] [X] [static]
- vol should in range [0, 1].
- vol 范围为 [0, 1]。
- vol should in range [0, 1].
Parameters参数パラメータ
name string vol number
Input[edit | edit source]
GetKeyState(code)
[P] [X] [static]
- Detail
- (P) code is VK_CODE defined by microsoft.
- (X) code is EventKeyboard::KeyCode defined by cocos2d-x.
- 细节
- (P) code 为微软定义的 VK_CODE。
- (X) code 为cocos2d-x定义的 EventKeyboard::KeyCode。
- Detail
- (P) code is VK_CODE defined by microsoft.
- (X) code is EventKeyboard::KeyCode defined by cocos2d-x.
Parameters参数パラメータ
code number
Return value返回值戻り値
- boolean
GetLastKey()
[P] [X] [static]
Return value返回值戻り値
- number
GetLastChar()
[P] [X] [static] [deprecated in X]
- (X) Do nothing.
- (X) 无作用。
- (X) Do nothing.
Return value返回值戻り値
- string
GetMousePosition()
[P] [X] [static]
Return value返回值戻り値
- number,number
GetMouseState(button)
[P] [X] [static]
- button specifies button to check. 0/1/2 correspond to left/middle/right.
- button 指定要检查的按键。0/1/2分别对应左/中/右。
- button specifies button to check. 0/1/2 correspond to left/middle/right.
Parameters参数パラメータ
button number
Return value返回值戻り値
- boolean
Misc[edit | edit source]
Snapshot(file_path)
[P] [X] [static]
Parameters参数パラメータ
file_path string
Execute(path, arguments, directory, wait)
[P] [static]
Parameters参数パラメータ
path string arguments string [optional] directory string [optional] wait boolean [optional] Default is true.
Return value返回值戻り値
- boolean
Math[edit | edit source]
sin(ang)
[P] [X] [static]
Parameters参数パラメータ
ang
cos(ang)
[P] [X] [static]
Parameters参数パラメータ
ang
asin(v)
[P] [X] [static]
Parameters参数パラメータ
v
acos(v)
[P] [X] [static]
Parameters参数パラメータ
v
tan(ang)
[P] [X] [static]
Parameters参数パラメータ
ang
atan(v)
[P] [X] [static]
Parameters参数パラメータ
v
atan2(y, x)
[P] [X] [static]
Parameters参数パラメータ
y x
Class Constructor[edit | edit source]
Rand()
[P] [X] [static]
Return value返回值戻り値
- RNG
Color(argb)
[P] [X] [static]
Parameters参数パラメータ
argb number
Return value返回值戻り値
- lstg::Color
Color(a, r, g, b)
[P] [X] [static]
Parameters参数パラメータ
a number r number g number b number
Return value返回值戻り値
- lstg::Color
BentLaserData()
[P] [X] [static]
Return value返回值戻り値
- BentLaserData
Debug[edit | edit source]
ObjTable()
[P] [X] [static]
Return value返回值戻り値
- table
Global Callback[edit | edit source]
GameInit()
[P] [X] [static]
FocusLoseFunc()
[P] [X] [static]
FocusGainFunc()
[P] [X] [static]
FrameFunc()
[P] [X] [static]
Return value返回值戻り値
- boolean
RenderFunc()
[P] [X] [static]
Color Class[edit | edit source]
- 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.
- Color 对象可以通过 Color() 创建。
- 分量 a, r, g, b 范围为 [0, 255]。
- 如无特殊说明,在数值计算时分量会被限制在 [0, 255]。
- (X) 分量可以通过 a, r, g, b 属性读写。
- (X) 32位值可以通过 argb 属性读写。
- (X) 在Lua脚本中扩展了其他方法和自定义构造函数。请参考LuaSTG-x的文档或源码。
- Color 对象是 Lua 中的 userdata。
- 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.
ARGB()
[P] [X]
Return value返回值戻り値
- number, number, number, number
unpack()
[X]
Return value返回值戻り値
- number, number, number, number
unpackFloat()
[X]
Return value返回值戻り値
- number, number, number, number
set(R, G, B, A)
[X]
Parameters参数パラメータ
R number G number B number A number [optional]
Return value返回值戻り値
- Color
setFloat(R, G, B, A)
[X]
Parameters参数パラメータ
R number G number B number A number [optional]
Return value返回值戻り値
- Color
clone()
[P] [X] [static]
Return value返回值戻り値
- Color
(meta)__eq(lhs, rhs)
[P] [X] [static]
Parameters参数パラメータ
lhs Color rhs Color
Return value返回值戻り値
- boolean
(meta)__add(lhs, rhs)
[P] [X] [static]
Parameters参数パラメータ
lhs Color rhs Color
Return value返回值戻り値
- Color
(meta)__sub(lhs, rhs)
[P] [X] [static]
Parameters参数パラメータ
lhs Color rhs Color
Return value返回值戻り値
- Color
(meta)__mul(lhs, rhs)
[P] [X] [static]
- 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.
当传入一个颜色对象和一个数值时:
- 将分量与数值相乘。
When passed with a color object and a number:
- Multiply components with a number.
Parameters参数パラメータ
lhs Color/number rhs Color/number
Return value返回值戻り値
- Color
(meta)__tostring(self)
[P] [X] [static]
Parameters参数パラメータ
self Color
Return value返回值戻り値
- string
RNG Class[edit | edit source]
- RNG object can be constructed by Rend().
- RNG class uses WELL512 algorithm.
- RNG 对象可以通过 Rend() 创建。
- RNG 类使用 WELL512 算法。
- RNG object can be constructed by Rend().
- RNG class uses WELL512 algorithm.
Seed(seed)
[P] [X]
Parameters参数パラメータ
seed number
GetSeed()
[P] [X]
Return value返回值戻り値
- number
Int(min, max)
[P] [X]
Parameters参数パラメータ
min number max number
Return value返回值戻り値
- number
Float(min, max)
[P] [X]
Parameters参数パラメータ
min number max number
Return value返回值戻り値
- number
Sign()
[P] [X]
Return value返回值戻り値
- number
BentLaserData Class[edit | edit source]
- BentLaserData object can be constructed by BentLaserData().
- BentLaserData 对象可以通过 BentLaserData() 创建。
- BentLaserData object can be constructed by BentLaserData().
Update(obj, length, width)
[P]
- length specifies the limit of node count.
- width specifies the width property of node.
- length 指定节点数量上限。
- width 指定节点的宽度属性。
- length specifies the limit of node count.
- width specifies the width property of node.
Parameters参数パラメータ
obj object length number width number
Release()
[P]
Render(texName, blend, color, texLeft, texTop, texWidth, texHeight, scale)
[P]
- texName specifies name of texture resource.
- blend specifies name of blend mode.
- color specifies color of all vertices.
- texLeft, texTop, texWidth, texHeight specifies texture coordinates in range [0, 1].
- scale specifies the scale apply to each node's width.
- texName 指定纹理资源名称。
- blend 指定混合模式名称。
- color 指定所有顶点的颜色。
- texLeft, texTop, texWidth, texHeight 指定纹理坐标,范围为 [0, 1]。
- scale 指定每个节点宽度的缩放。
- texName specifies name of texture resource.
- blend specifies name of blend mode.
- color specifies color of all vertices.
- texLeft, texTop, texWidth, texHeight specifies texture coordinates in range [0, 1].
- scale specifies the scale apply to each node's width.
Parameters参数パラメータ
texName string blend string color lstg::Color texLeft number texTop number texWidth number texHeight number scale number
CollisionCheck(x, y, rot, a, b, rect)
[P]
Returns true is there is collision.
- Detail
- Each node will be treated as a circle whose radius is half of the width.
若发生碰撞则返回 true 。
- 细节
- 每个节点将被当作一个半径为其宽度一半的圆。
Returns true is there is collision.
- Detail
- Each node will be treated as a circle whose radius is half of the width.
Parameters参数パラメータ
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.
Return value返回值戻り値
- boolean
BoundCheck()
[P]
Return value返回值戻り値
- boolean