|
LuaSTG-x Core API
|
cc.RenderTexture More...
Classes | |
| class | soundVolume |
Public Attributes | |
| number | GOLD = 360 * (math.sqrt(5) - 1) / 2 |
| 0.618*360 More... | |
| number | GROUP_ALL = 16 |
| number | GROUP_ENEMY = 2 |
| number | GROUP_ENEMY_BULLET = 1 |
| number | GROUP_GHOST = 0 |
| number | GROUP_INDES = 5 |
| number | GROUP_ITEM = 6 |
| number | GROUP_NONTJT = 7 |
| number | GROUP_NUM_OF_GROUP = 16 |
| number | GROUP_PLAYER = 4 |
| number | GROUP_PLAYER_BULLET = 3 |
| number | LAYER_BG = -700 |
| number | LAYER_ENEMY = -600 |
| number | LAYER_ENEMY_BULLET = -200 |
| number | LAYER_ENEMY_BULLET_EF = -100 |
| number | LAYER_ITEM = -300 |
| number | LAYER_PLAYER = -400 |
| number | LAYER_PLAYER_BULLET = -500 |
| number | LAYER_TOP = 0 |
| number | PI = math.pi |
| π. More... | |
| number | PI_2 = math.pi * 0.5 |
| π/2. More... | |
| number | PI_4 = math.pi * 0.25 |
| π/4. More... | |
| number | PIx2 = math.pi * 2 |
| π*2. More... | |
| number | SQRT2 = math.sqrt(2) |
| √2 More... | |
| number | SQRT2_2 = math.sqrt(0.5) |
| √2/2 More... | |
| number | SQRT3 = math.sqrt(3) |
| √3 More... | |
cc.RenderTexture
一个全局变量(非函数),内部储存有全局环境。Lua 自己不使用这个变量;
改变这个变量的值不会对任何环境造成影响,反之亦然。
init score data
score/mod_name
| static function _DoFrame | ( | ) |
| static function _SetBound | ( | ) |
屏幕宽度
屏幕高度
| static function AfterFrame | ( | ) |
刷新对象的timer和ani_timer,若对象被标记为del或kill将删除对象并回收资源。
禁止在协程上调用该方法。
细节
> 对象只有在AfterFrame调用后才会被清理,在此之前可以通过设置对象的status字段取消删除标记。
| static function AfterRender | ( | ) |
计算两点连线角度
当参数个数为2时,返回2个object连线角度
当参数个数为4时,返回2个坐标连线角度
| arg1 | object|number object或x1 |
| arg2 | object|number object或y1 |
| arg3 | number x2 |
| arg4 | number y2 |
| static function BeforeRender | ( | ) |
| static function BeginScene | ( | ) |
通知开始渲染。该方法必须在RenderFunc中调用。所有渲染动作必须在BeginScene/EndScene中进行。
| static function BentLaserData | ( | ) |
创建并返回曲线激光类
| static function BoundCheck | ( | ) |
执行边界检查。注意BoundCheck只保证对象中心还在范围内,不进行碰撞盒检查
禁止在协程上调用该方法
将bound==true并且x,y在SetBound设置范围外的所有对象状态置为'del'
检查对象中心是否在所给范围内
| object | object |
| left | number |
| right | number |
| bottom | number |
| top | number |
计算文字渲染后的尺寸
| name | string |
| str | string |
x,y,w,h are in ui coords
| obj | object |
| x | number |
| y | number |
| w | number |
| h | number |
改变视频选项。若成功返回true,否则返回false
| width | number |
| height | number |
| windowed | boolean |
| vsync | boolean |
获得一个资源所在资源池的类别,通常用于检测资源是否存在
细节
方法会根据名称先在全局资源池中寻找,若有则返回global
若全局资源表中没有找到资源,则在关卡资源池中找,若有则返回stage
若不存在资源,则返回nil
| resType | string 资源类型 tex,img,ani,bgm,snd,psi,fnt,ttf,fx |
| name | string 资源名 |
定义类
| base | object 基类 |
| define | table 需要额外继承的表,通常与base相同 |
对组A和B进行碰撞检测。如果组A中对象与组B中对象发生碰撞,将执行A中对象的碰撞回调函数。
禁止在协程上调用该方法。
| A | number|object |
| B | number|object |
| static function CopyFrameBuffer | ( | ) |
| static function CreateRenderMode | ( | local | name, |
| local | blendEquation, | ||
| local | blendFuncSrc, | ||
| local | blendFuncDst, | ||
| local | shaderName | ||
| ) |
设置雾值
若参数为空,将关闭雾效果。否则设置一个从near到far的雾
| near | number |
| far | number |
| color | lstg.Color 默认为0x00FFFFFF |
| vert | string |
| frag | string |
| vert | string |
| frag | string |
通知删除一个对象。将设置标志并调用回调函数。
若在object后传递多个参数,将被传递给回调函数。
| obj | object |
计算两个object距离
| objA | object |
| objB | object |
keycode
执行指定路径的脚本。已执行过的脚本会再次执行。
若文件不存在、编译失败、执行失败则抛出错误。
| path | string |
| static function DoFrame | ( | ) |
| static function DrawCollider | ( | ) |
DrawGroupCollider
| group | number |
| color | lstg.Color |
| offset_x | number |
| offset_y | number |
| static function EndScene | ( | ) |
通知结束渲染。该方法必须在RenderFunc中调用。
枚举资源池中某种类型的资源
依次返回全局资源池、关卡资源池中该类型的所有资源的名称
| resType | string 资源类型: tex,img,ani,bgm,snd,psi,fnt,ttf,fx |
| static function FocusGainFunc | ( | ) |
| static function FocusLoseFunc | ( | ) |
| static function FrameEnd | ( | ) |
| static function FrameFunc | ( | ) |
| static function FrameInit | ( | ) |
| static function FrameReset | ( | ) |
| static function GameExit | ( | ) |
| static function GameInit | ( | ) |
游戏初始化
| static function GetAllControllers | ( | ) |
| static function GetFPS | ( | ) |
获得当前的实时FPS。
| static function GetFrameBuffer | ( | ) |
| static function GetImageScale | ( | ) |
获取全局图像渲染缩放
| static function GetInput | ( | ) |
获取输入并保存
| static function GetLastChar | ( | ) |
返回最后一次输入的按键的虚拟键代码
| static function GetLastKey | ( | ) |
返回最后一次输入的按键的虚拟键代码
| static function GetMousePosition | ( | ) |
获取鼠标的位置,以窗口左下角为原点,使用screen坐标系
获取鼠标的位置,以窗口左下角为原点
| button | number 可取0、1、2,分别对应鼠标左键、中键、右键 |
获取音乐播放状态
| name | string |
| static function GetnObj | ( | ) |
获取对象池中对象个数
| object | object |
| static function GetPlatform | ( | ) |
获取音效播放状态
| name | string |
| static function GetThreadPoolSize | ( | ) |
获取速度方向和大小(C++对象)
| obj | object |
脚本搜索路径
包含(执行)脚本文件
| filename | string |
检查一个纹理是否为RenderTarget
IsValid(obj)
检查对象是否有效
对象为table,且具有正确的资源池id
| obj | object |
key是否被按下
key是否刚刚被按下 key是否刚刚松开
| key | string |
通知杀死一个对象。将设置标志并调用回调函数。
若在object后传递多个参数,将被传递给回调函数。
| obj | object |
| static function LoadAniFromFile | ( | local | texaniname, |
| local | filename, | ||
| local | mipmap, | ||
| local | n, | ||
| local | m, | ||
| local | intv, | ||
| local | a, | ||
| local | b, | ||
| local | rect | ||
| ) |
从文件载入动画
| texaniname | string 资源名 |
| filename | string 文件名 |
| mipmap | boolean 创建Mipmap链,用于加快图像渲染,对动态纹理和渲染目标无效 |
| n | number 行数 |
| m | number 列数 |
| intv | number 动画间隔(帧) 最小为1 |
| a | number 横向碰撞大小的一半 |
| b | number 纵向碰撞大小的一半 |
| rect | boolean 是否为矩形碰撞盒 |
| static function LoadAnimation | ( | local | name, |
| local | tex_name, | ||
| local | x, | ||
| local | y, | ||
| local | w, | ||
| local | h, | ||
| local | nCol, | ||
| local | nRow, | ||
| local | interval, | ||
| local | a, | ||
| local | b, | ||
| local | colliType | ||
| ) |
装载动画
动画总是循环播放的
| name | string |
| tex_name | string |
| x | number |
| y | number 第一帧的左上角位置 |
| w | number |
| h | number 一帧的大小 |
| nCol | number |
| nRow | number 纵向横向的分割数,以列优先顺序排列 |
| interval | number 帧间隔 |
| a | number |
| b | number |
| colliType | boolean 同LoadImage |
装载纹理字体
支持HGE的纹理字体,将根据定义文件在字体同级目录下寻找纹理文件
| name | string 名称 |
| path | string 定义文件 |
载入FX文件(shader特效)
| name | string |
| fShader | string fragment shader路径/内容,默认为shader/ColorMulti.frag |
| vShaderpath | string vertex shader路径/内容,默认为shader/Common.vert |
| isString | boolean 指示fShader和vShader为shader内容还是路径 |
| static function LoadImage | ( | local | name, |
| local | tex_name, | ||
| local | x, | ||
| local | y, | ||
| local | w, | ||
| local | h, | ||
| local | a, | ||
| local | b, | ||
| local | colliType | ||
| ) |
在纹理中创建图像
细节
当把一个图像赋予对象的img字段时,它的a、b、rect属性会自动被赋值到对象上
| name | string |
| tex_name | string |
| x | number |
| y | number 图像在纹理上左上角的坐标(纹理左上角为(0,0),向下向右为正方向) |
| w | number |
| h | number 图像的大小 |
| a | number |
| b | number 横向、纵向碰撞半径 |
| colliType | boolean|number|string 判定形状 |
| static function LoadImageFromFile | ( | local | name, |
| local | filename, | ||
| local | mipmap, | ||
| local | a, | ||
| local | b, | ||
| local | rect | ||
| ) |
从文件载入图像
| name | string 资源名 |
| filename | string 文件名 |
| mipmap | boolean |
| a | number |
| b | number 碰撞半径 省略为0 |
| rect | boolean 是否为矩形碰撞盒 省略为false |
| static function LoadImageGroup | ( | local | prefix, |
| local | texname, | ||
| local | x, | ||
| local | y, | ||
| local | w, | ||
| local | h, | ||
| local | cols, | ||
| local | rows, | ||
| local | a, | ||
| local | b, | ||
| local | rect | ||
| ) |
从纹理资源载入图像组
| prefix | string 资源名前缀 |
| texname | string 纹理资源名 |
| x | number |
| y | number 起始坐标 |
| w | number |
| h | number 单个图像尺寸 |
| cols | number |
| rows | number 行列数 |
| a | number |
| b | number 碰撞半径 省略为0 |
| rect | boolean 是否为矩形碰撞盒 省略为false |
| static function LoadImageGroupFromFile | ( | local | texaniname, |
| local | filename, | ||
| local | mipmap, | ||
| local | n, | ||
| local | m, | ||
| local | a, | ||
| local | b, | ||
| local | rect | ||
| ) |
从文件载入图像组
通常使用_LoadImageGroupFromFile代替
| texaniname | string 资源名 |
| filename | string 文件名 |
| mipmap | boolean |
| n | number 行数 |
| m | number 列数 |
| a | number 横向碰撞大小的一半 |
| b | number 纵向碰撞大小的一半 |
| rect | boolean 是否为矩形碰撞盒 |
加载音乐
仅支持wav或ogg,推荐使用ogg格式
细节
音乐将以流的形式装载进入内存,不会一次性完整解码放入内存
通过描述循环节可以设置音乐的循环片段。当音乐位置播放到end时会衔接到start。这一步在解码器中进行,以保证完美衔接
| name | string 资源名 |
| path | string 文件路径 |
| loop_end | number 循环结束(秒) |
| loop_duration | number 循环时长(秒) |
| static function LoadMusicAsync | ( | local | name, |
| local | path, | ||
| local | loop_end, | ||
| local | loop_duration, | ||
| local | callback | ||
| ) |
加载指定位置的ZIP资源包,可选填密码
失败将导致错误
细节
后加载的资源包有较高的查找优先级。这意味着可以通过该机制加载资源包来覆盖基础资源包中的文件。
一旦zip文件被打开,将不能被访问。
加载文件时将按照优先级依次搜索资源包,若资源包中不含文件则从当前目录加载。
| path | string |
| password | string @optional |
| static function LoadPS | ( | local | name, |
| local | path, | ||
| local | img_name, | ||
| local | a, | ||
| local | b, | ||
| local | colliType | ||
| ) |
装载粒子系统
使用HGE所用的粒子文件结构
| name | string |
| path | string 定义文件 |
| img_name | string 粒子图片 |
| a | number |
| b | number |
| colliType | boolean |
| static function LoadPSAsync | ( | local | name, |
| local | path, | ||
| local | img_name, | ||
| local | a, | ||
| local | b, | ||
| local | colliType, | ||
| local | callback | ||
| ) |
装载音效
仅支持wav或ogg,推荐使用wav格式
细节
音效将被装载进入内存。请勿使用较长的音频文件做音效
对于wav格式,由于受限于目前的实现,不支持非标准的、带压缩的格式
| name | string 资源名 |
| path | string 文件路径 |
MouseIsPressed
| button | number |
MouseIsReleased
| button | number |
| static function MousePosition | ( | ) |
| static function MousePositionPre | ( | ) |
创建新对象,将累加uid值
细节
该方法使用class创建一个对象,并在构造对象后调用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被用于存放类和id【请勿修改】
其中父类class需满足如下形式:
is_class = true
[1] = 初始化函数 (object, ...)
[2] = 删除函数(DEL) (object, ...)
[3] = 帧函数 (object)
[4] = 渲染函数 (object)
[5] = 碰撞函数 (object, object)
[6] = 消亡函数(KILL) (object, ...)
上述回调函数将在对象触发相应事件时被调用
引擎提供了至多32768个空间共object使用。超过这个大小后将报错。
获取组中的下一个元素。若groupid为无效的碰撞组则返回所有对象。
返回的第一个参数为id,第二个参数为对象
| groupid | number |
| id | number |
| static function ObjFrame | ( | ) |
更新对象列表中所有对象,并更新属性
禁止在协程上调用该方法
细节
按照下列顺序更新这些属性:
vx += ax
vy += ay
x += vx
y += vy
rot += omiga
更新绑定的粒子系统(若有)
产生组遍历迭代器
for id, obj in ObjList(GROUP_PLAYER) do
...
end
| groupid | number |
| static function ObjRender | ( | ) |
渲染所有对象。此时将所有对象排序。
禁止在协程上调用该方法。
排序规则:layer小的先渲染,若layer相同则按照uid
细节
渲染列表总是保持有序的,将不会每次排序
| static function ObjTable | ( | ) |
获得对象池所在的table
获取绑定在对象上粒子发射器的发射密度(个/秒)
细节
更新粒子发射器的时钟始终为1/60s
| object | object |
设置绑定在对象上粒子发射器的发射密度(个/秒)
| object | object |
| count | number |
播放音乐
| name | string 资源名 |
| vol | number 音量系数,默认为1 |
| position | number 起始播放位置(秒),默认为0 |
| name | string 音效资源名 |
| vol | number 音量 |
| pan | number 声道平衡 |
| name | string 音效资源名 |
| vol | number 音量 |
| pan | number 声道平衡 |
| sndflag | boolean 不使用默认音量 |
应用PostEffect(不论是否处于渲染状态)。参数指定传递给FX的参数表,将会影响后续对该FX的使用
其中blend指定posteffect要以什么样的形式绘制到屏幕上,此时blend的第一分量无效
细节
可以在PostEffect中使用下列语义注释(不区分大小写)捕获对象:
POSTEFFECTTEXTURE获取posteffect的捕获纹理(texture2d类型)
VIEWPORT获取视口大小(vector类型)
SCREENSIZE获取屏幕大小(vector类型)
| rt | lstg.ResRenderTarget|string |
| fx | lstg.ResFX|string |
| blend | lstg.RenderMode|string |
| param | table |
结束屏幕捕获并应用PostEffect
这一操作等价于:
PopRenderTarget(InternalPostEffectBuffer)
PostEffect(InternalPostEffectBuffer, fx_name, blend, args)
代码必须满足:
PostEffectCapture(...)
... –配对的Push/PopRenderTarget操作
PostEffectApply(...)
| fx | lstg.ResFX|string |
| blend_mode | lstg.RenderMode|string |
| param | table 其中key表示uniform变量名,value可以是数值、字符串(纹理名)、颜色 |
| static function PostEffectCapture | ( | ) |
开始捕获绘制数据
从这一步开始,所有后续渲染操作都将在PostEffect缓冲区中进行
这一操作等价于PushRenderTarget(InternalPostEffectBuffer)
将一个RenderTarget作为屏幕缓冲区,并推入栈
细节
引擎底层使用栈来管理RenderTarget,这意味着可以嵌套使用
| name | string |
| static function RegistClasses | ( | ) |
object
若只有一个参数,则删除一个池中的所有资源。否则删除对应池中的某个资源。参数可选global或stage。
若资源仍在使用之中,将继续保持装载直到相关的对象被释放。
| poolType | string |
| resType | string |
| name | string |
| static function Render | ( | local | name, |
| local | x, | ||
| local | y, | ||
| local | rot, | ||
| local | hscale, | ||
| local | vscale, | ||
| local | z | ||
| ) |
渲染图像
| name | string 图像资源名 |
| x | number |
| y | number 渲染位置 |
| rot | number 旋转角度(角度),默认为0 |
| hscale | number 水平缩放,默认为1 |
| vscale | number 垂直缩放,默认等于hscale |
| z | number Z值,默认为0.5 |
| static function Render4V | ( | local | name, |
| local | x1, | ||
| local | y1, | ||
| local | z1, | ||
| local | x2, | ||
| local | y2, | ||
| local | z2, | ||
| local | x3, | ||
| local | y3, | ||
| local | z3, | ||
| local | x4, | ||
| local | y4, | ||
| local | z4 | ||
| ) |
给出四个顶点渲染图像
| name | string |
| x1 | number |
| y1 | number |
| z1 | number |
| x2 | number |
| y2 | number |
| z2 | number |
| x3 | number |
| y3 | number |
| z3 | number |
| x4 | number |
| y4 | number |
| z4 | number |
使用指定颜色清空屏幕,同时会清除深度缓冲区
| color | lstg.Color |
| static function RenderFunc | ( | ) |
在一个矩形范围渲染图像
此时z=0.5
| name | string |
| left | number |
| right | number |
| bottom | number |
| top | number |
| static function RenderSector | ( | local | name, |
| local | x, | ||
| local | y, | ||
| local | start, | ||
| local | end_, | ||
| local | r1, | ||
| local | r2, | ||
| local | seg | ||
| ) |
将图像渲染到扇形区域(可用于绘制圆环)
| name | string |
| x | number |
| y | number 圆心位置 |
| start | number 起始角度(角度) |
| end_ | number 终止角度(角度) |
| r1 | number 内圆半径 |
| r2 | number 外圆半径 |
| seg | number 每圆周分割段数,默认为60 |
直接渲染文本
fontname:已载入的字体名
text:文本
x,y:对齐点
size:文本缩放
...:文本格式 如:'left', 'top'
使用纹理字体渲染一段文字
name: 纹理名称,text: 字符串,x、y: 坐标,align: 对齐模式
该函数受全局图像缩放系数影响
细节
对齐模式指定渲染中心,对齐模式可取值:
左上 0 中上 1 右上 2
左中 4 中中 5 右中 6
左下 8 中下 9 右下 10
由于使用了新的布局机制,在渲染HGE字体时在横向上会有少许误差,请手动调整
| name | string |
| text | string |
| x | number |
| y | number |
| scale | number |
| align | number |
| static function RenderTexture | ( | local | name, |
| local | blend, | ||
| local | vertex1, | ||
| local | vertex2, | ||
| local | vertex3, | ||
| local | vertex4 | ||
| ) |
直接渲染纹理。
细节
vertex1~4指定各个顶点坐标,其中必须包含以下项:
[1] = X坐标
[2] = Y坐标
[3] = Z坐标
[4] = U坐标(以纹理大小为区间)
[5] = V坐标(以纹理大小为区间)
[6] = 顶点颜色
注意该函数效率较低,若要使用请考虑缓存顶点所用table
| name | string |
| blend | string |
| vertex1 | table |
| vertex2 | table |
| vertex3 | table |
| vertex4 | table |
| static function RenderTTF | ( | local | name, |
| local | text, | ||
| local | left, | ||
| local | right, | ||
| local | bottom, | ||
| local | top, | ||
| local | fmt, | ||
| local | color, | ||
| local | scale | ||
| ) |
渲染TTF字体
该函数受全局图像缩放系数影响
细节
暂时不支持渲染格式设置
若省略从fmt开始的参数,则值为字体资源设置的值
| name | string |
| text | string |
| left | number |
| right | number |
| bottom | number |
| top | number |
| fmt | number |
| color | lstg.Color |
| scale | number |
| static function RenderTTF | ( | local | ttfname, |
| local | text, | ||
| local | left, | ||
| local | right, | ||
| local | bottom, | ||
| local | top, | ||
| local | color, | ||
| local ... | |||
| ) |
渲染TTF
| ttfname | string 字体资源名 |
| text | string 文本 |
| left | number |
| right | number |
| bottom | number |
| top | number 文本区域 |
| color | lstg.Color 文本颜色 |
| scale | number 文本缩放,可省略 |
| ... | any 文本格式 如:'left', 'top' |
包括:left,center,right,top,vcenter,bottom,wordbreak,noclip,paragraph,centerpoints
| static function Reset3D | ( | ) |
重置3D变量
| static function ResetPool | ( | ) |
清空并回收所有对象
| static function SaveScoreData | ( | ) |
save scoredata to file
| static function Screenshot | ( | ) |
类似于SetImageCenter
| static function SetAnimationState | ( | local | name, |
| local | blendMode, | ||
| local | color1, | ||
| local | color2, | ||
| local | color3, | ||
| local | color4 | ||
| ) |
类似于SetImageState
设置对象属性(C++或lua对象的属性)
| obj | object |
| key | string |
| v | any |
传入1个参数时,设置全局音乐音量,将影响后续播放音乐的音量
传入2个参数时,设置指定音乐音量
音量值范围为[0, 1]
| arg1 | number|string |
| arg2 | number |
设置舞台边界
| left | number |
| right | number |
| bottom | number |
| top | number |
设置图像中心
| name | string 图像资源名 |
| x | number |
| y | number 相对于图像左上角的坐标 |
| static function SetImageState | ( | local | name, |
| local | blendMode, | ||
| local | color1, | ||
| local | color2, | ||
| local | color3, | ||
| local | color4 | ||
| ) |
设置图像状态,可选一个颜色参数用于设置所有顶点或者给出4个颜色设置所有顶点。
混合模式可选
"" 默认值,=mul+alpha
"mul+add" 顶点颜色使用乘法,目标混合使用加法
"mul+alpha" (默认)顶点颜色使用乘法,目标混合使用alpha混合
"mul+sub" 顶点颜色使用乘法,结果=图像上的颜色-屏幕上的颜色
"mul+rev" 顶点颜色使用乘法,结果=屏幕上的颜色-图像上的颜色
"add+add" 顶点颜色使用加法,目标混合使用加法
"add+alpha" 顶点颜色使用加法,目标混合使用alpha混合
"add+sub" 顶点颜色使用加法,结果=图像上的颜色-屏幕上的颜色
"add+rev" 顶点颜色使用加法,结果=屏幕上的颜色-图像上的颜色
| name | string 图像资源名 |
| blendMode | string 混合模式 |
| color1 | lstg.Color 混合颜色 |
设置资源状态
该函数将会设置和对象绑定的精灵、动画资源的混合模式,该设置对所有同名资源都有效果
| object | object |
| blend | string 混合模式 |
| a | number |
| r | number |
| g | number |
| b | number 颜色 |
| f | fun(controller:cc.Controller, keyCode:number, value:number, isPressed:boolean, isAnalog:boolean) |
| f | fun(controller:cc.Controller, keyCode:number, value:number, isPressed:boolean, isAnalog:boolean) |
| f | fun(controller:cc.Controller, keyCode:number, value:number, isPressed:boolean, isAnalog:boolean) |
设置正投影矩阵
创建的正投影矩阵将把z轴限制在[-1024, 1024]区间内
| left | number |
| right | number |
| bottom | number |
| top | number |
| static function SetPerspective | ( | local | eyeX, |
| local | eyeY, | ||
| local | eyeZ, | ||
| local | atX, | ||
| local | atY, | ||
| local | atZ, | ||
| local | upX, | ||
| local | upY, | ||
| local | upZ, | ||
| local | fovy, | ||
| local | aspect, | ||
| local | zn, | ||
| local | zf | ||
| ) |
设置透视投影矩阵
(eyeX,eyeY,eyeZ)表示观察者位置
(atX,atY,atZ)表示观察目标
(upX,upY,upZ)用于表示观察者向上的正方向
fovy描述视角范围(弧度)
aspect描述宽高比
zn和zf描述z轴裁剪距离
| eyeX | number |
| eyeY | number |
| eyeZ | number |
| atX | number |
| atY | number |
| atZ | number |
| upX | number |
| upY | number |
| upZ | number |
| fovy | number |
| aspect | number |
| zn | number |
| zf | number |
设置窗口大小
可以在运行时动态设置
| width | number |
| height | number |
设置当前激活的资源池类型
| poolType | string stage/global |
传入1个参数时,设置全局音效音量,将影响后续播放音效的音量
传入2个参数时,设置指定音效音量
音量值范围为[0, 1]
| arg1 | number|string |
| arg2 | number |
设置shader中的uniform变量
| fx | string |
| param | table |
设置速度方向和大小(C++对象)
| obj | object 要设置的对象 |
| v | number 速度大小 |
| angle | number 速度方向(角度) |
| updateRot | boolean 是否更新自转,默认为false |
设置对象的速度
| obj | object 要设置的对象 |
| v | number 速度大小 |
| angle | number 速度方向(角度) |
| updateRot | boolean 是否更新自转 |
| aim | boolean 方向是否相对自机 |
设置视角模式: 3d world ui
'world': 对应lstrg.world
'ui': 对应screen坐标系
'3d': 对应lstg.view3d
| mode | string |
设置视口,将影响裁剪和渲染。
| left | number |
| right | number |
| bottom | number |
| top | number |
| static function stringify | ( | local | this, |
| local | docol, | ||
| local | spacing_h, | ||
| local | spacing_v, | ||
| local | preindent | ||
| ) |
序列化为字符串
| static function UpdateXY | ( | ) |
刷新对象的dx,dy,lastx,lasty,rot(若navi==true)属性值
禁止在协程上调用该方法。
| static function UserSystemOperation | ( | ) |
坐标系变换
计算结果结果并非实际屏幕坐标系,而是screen的坐标系
用于boss扭曲效果时请将结果加上screen.dx和screen.dy
Extends [Class] function so that you can use ClassName(...) to create an instance of lstg object.
Example: classname = xclass(object)
| base | object |
| define | table |
| number GROUP_ALL = 16 |
| number GROUP_ENEMY = 2 |
| number GROUP_ENEMY_BULLET = 1 |
| number GROUP_GHOST = 0 |
| number GROUP_INDES = 5 |
| number GROUP_ITEM = 6 |
| number GROUP_NONTJT = 7 |
| number GROUP_NUM_OF_GROUP = 16 |
| number GROUP_PLAYER = 4 |
| number GROUP_PLAYER_BULLET = 3 |
| number LAYER_BG = -700 |
| number LAYER_ENEMY = -600 |
| number LAYER_ENEMY_BULLET = -200 |
| number LAYER_ENEMY_BULLET_EF = -100 |
| number LAYER_ITEM = -300 |
| number LAYER_PLAYER = -400 |
| number LAYER_PLAYER_BULLET = -500 |
| number LAYER_TOP = 0 |