S-C-Link 库(服务端)
用于通过服务端渲染客户端内容的库
依赖EasyBox3Lib 0.1.6
(为什么使用Game开头的API?因为GUI是新岛专属())
- Version
- 0.0.3
- License
- MIT
- Source
- Version
- 0.0.3
- License
- MIT
- Source
Classes
Members
(inner, constant) CONFIG
配置文件
- Source
(inner, constant) EBL_VERSION :Array.<number>
建议EasyBox3Lib版本
- Array.<number>
- Source
(inner, constant) VERSION :Array.<number>
当前版本
- Array.<number>
- Source
(inner, constant) NodeType :string
节点类型
- string
| Name | Type | Description |
|---|---|---|
BOX | string | |
TEXT | string | |
IMAGE | string | |
INPUT | string | |
ROOT | string |
- Source
(inner, constant) EventName :string
事件类型
- string
| Name | Type | Description |
|---|---|---|
onPress | string | |
onRelease | string | |
onFocus | string | |
onBlur | string | |
onLockChange | string | |
onLockError | string |
- Source
(inner) textXAlignment :string|number
若节点为文本,则为节点的水平对齐方式 -1 等同于 Left,表示左对齐0 等同于 Center,表示居中1 等同于 Right,表示右对齐 若不是文本,保留该属性,但不生效
若为其他的值,则以居中渲染
- string |
number
- Source
(inner) textYAlignment :string|number
若节点为文本,则为节点的垂直对齐方式 -1 等同于 Top,表示左对齐0 等同于 Center,表示居中1 等同于 Bottom,表示右对齐 若不是文本,保留该属性,但不生效
若为其他的值,则以居中渲染
- string |
number
- Source
(inner) textColor :GameRGBColor
若节点为文本,则为文字颜色
若不是文本,保留该属性,但不生效
- GameRGBColor
- Source
(inner) backgroundColor :GameRGBAColor
节点背景颜色
- GameRGBAColor
- Source
(inner) placeholderColor :GameRGBAColor
若节点是输入框,表示占位文本背景颜色
若不是输入框,保留该属性,但不生效
- GameRGBAColor
- Source
(inner) zIndex :number
节点的层级,用于确定节点的渲染顺序。
若为null,则听天由命浏览器会自行处理
- number
- Source
(inner) textFontSize :number
若节点为文本,则为文字字号
若不是文本,保留该属性,但不生效
- number
- Source
(inner) imageOpacity :number
若节点是图片,表示图片不透明度
若不是输入框,保留该属性,但不生效
- number
- Source
(inner) enable :boolean
自身是否响应
- boolean
- Source
(inner) passThrough :boolean
自身后方的其他元素是否响应
- boolean
- Source
(inner) args :PackedData
- PackedData
- Source
(inner, constant) CONFIG
配置文件
- Source
(inner, constant) EBL_VERSION :Array.<number>
建议EasyBox3Lib版本
- Array.<number>
- Source
(inner, constant) VERSION :Array.<number>
当前版本
- Array.<number>
- Source
(inner, constant) NodeType :string
节点类型
- string
| Name | Type | Description |
|---|---|---|
BOX | string | |
TEXT | string | |
IMAGE | string | |
INPUT | string | |
ROOT | string |
- Source
(inner, constant) EventName :string
事件类型
- string
| Name | Type | Description |
|---|---|---|
onPress | string | |
onRelease | string | |
onFocus | string | |
onBlur | string | |
onLockChange | string | |
onLockError | string |
- Source
(inner) textXAlignment :string|number
若节点为文本,则为节点的水平对齐方式 -1 等同于 Left,表示左对齐0 等同于 Center,表示居中1 等同于 Right,表示右对齐 若不是文本,保留该属性,但不生效
若为其他的值,则以居中渲染
- string |
number
- Source
(inner) textYAlignment :string|number
若节点为文本,则为节点的垂直对齐方式 -1 等同于 Top,表示左对齐0 等同于 Center,表示居中1 等同于 Bottom,表示右对齐 若不是文本,保留该属性,但不生效
若为其他的值,则以居中渲染
- string |
number
- Source
(inner) textColor :GameRGBColor
若节点为文本,则为文字颜色
若不是文本,保留该属性,但不生效
- GameRGBColor
- Source
(inner) backgroundColor :GameRGBAColor
节点背景颜色
- GameRGBAColor
- Source
(inner) placeholderColor :GameRGBAColor
若节点是输入框,表示占位文本背景颜色
若不是输入框,保留该属性,但不生效
- GameRGBAColor
- Source
(inner) zIndex :number
节点的层级,用于确定节点的渲染顺序。
若为null,则听天由命浏览器会自行处理
- number
- Source
(inner) textFontSize :number
若节点为文本,则为文字字号
若不是文本,保留该属性,但不生效
- number
- Source
(inner) imageOpacity :number
若节点是图片,表示图片不透明度
若不是输入框,保留该属性,但不生效
- number
- Source
(inner) enable :boolean
自身是否响应
- boolean
- Source
(inner) passThrough :boolean
自身后方的其他元素是否响应
- boolean
- Source
(inner) args :PackedData
- PackedData
- Source
Methods
(inner) renderNode(node, entity, parentId, idnullable) → {number}
渲染节点
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
node | NodeBlueprint | 要渲染的节点 | ||
entity | GameEntity | 要进行渲染的玩家 | ||
parentId | number | 0 | 父节点id,默认为 | |
id | number | <nullable> | null | 节点id,可不填。若填写已经存在的id,则表示重新渲染已经渲染的节点。 |
- Source
打包后的节点id。此id是修改和删除该节点的唯一标识
- Type:
- number
(inner) removeNode(id, entity)
移除节点
| Name | Type | Description |
|---|---|---|
id | number | 要移除的节点序号。若填写无效数据,则在客户端抛出错误 |
entity | GameEntity | 要进行移除节点的玩家 |
- Source
(inner) sendClientEvent(data, …entities)
发送客户端事件
| Name | Type | Attributes | Description |
|---|---|---|---|
data | PackedData | ||
entities | GameEntity | <repeatable> |
- Source
(inner) BSOD(entity, …message)
对指定玩家抛出错误
| Name | Type | Attributes | Description |
|---|---|---|---|
entity | GameEntity | 要抛出错误的玩家 | |
message | string | <repeatable> | 错误消息 |
- Source
(inner) renderNode(node, entity, parentId, idnullable) → {number}
渲染节点
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
node | NodeBlueprint | 要渲染的节点 | ||
entity | GameEntity | 要进行渲染的玩家 | ||
parentId | number | 0 | 父节点id,默认为 | |
id | number | <nullable> | null | 节点id,可不填。若填写已经存在的id,则表示重新渲染已经渲染的节点。 |
- Source
打包后的节点id。此id是修改和删除该节点的唯一标识
- Type:
- number
(inner) removeNode(id, entity)
移除节点
| Name | Type | Description |
|---|---|---|
id | number | 要移除的节点序号。若填写无效数据,则在客户端抛出错误 |
entity | GameEntity | 要进行移除节点的玩家 |
- Source
(inner) sendClientEvent(data, …entities)
发送客户端事件
| Name | Type | Attributes | Description |
|---|---|---|---|
data | PackedData | ||
entities | GameEntity | <repeatable> |
- Source
(inner) BSOD(entity, …message)
对指定玩家抛出错误
| Name | Type | Attributes | Description |
|---|---|---|---|
entity | GameEntity | 要抛出错误的玩家 | |
message | string | <repeatable> | 错误消息 |
- Source
Type Definitions
EventCallBack(target, entity) → {void}
事件回调函数
| Name | Type | Description |
|---|---|---|
target | PackedNode | 目标节点 |
entity | GameEntity | 对应玩家 |
- Source
- Type:
- void
PackedNode
打包后的节点
| Name | Type | Attributes | Description |
|---|---|---|---|
protocols | "renderMessage" | | 事件协议,打包节点所需的协议只有 | |
id | number | 节点序号 | |
name | string | <nullable> | 节点名称,只在 |
data | object | <nullable> | 节点自定义数量,只在 |
style | NodeStyle | <nullable> | 节点样式,只在 |
content | string | <nullable> | 节点内容,只在 |
pointerEventBehavior | number | <nullable> | 界面元素对指针事件的行为方式,只在 |
autoResize | string | <nullable> | 节点自动调整尺寸的方式,只在 |
visible | boolean | <nullable> | 节点的可见性,只在 |
placeholder | string | <nullable> | 节点占位文本内容,只在 |
size | Coord2 | <nullable> | 节点大小,只在 |
position | Coord2 | <nullable> | 节点位置,只在 |
anchor | Vector2 | <nullable> | 节点锚点,只在 |
parent | number | <nullable> | 父节点id |
childern | Array.<PackedNode> | <nullable> | 子节点,只在 |
type | NodeType | <nullable> | 节点类型,只在 |
events | PackedNodeEvent | <nullable> | 打包后的节点事件 |
- Source
NodeStyle
节点样式
| Name | Type | Description |
|---|---|---|
textXAlignment | string | | 若节点为文本,则为节点的水平对齐方式 |
textYAlignment | string | | 若节点为文本,则为节点的垂直对齐方式 |
textColor | GameRGBColor | 若节点为文本,则为文字颜色 |
backgroundColor | GameRGBAColor | 节点背景颜色 |
placeholderColor | GameRGBAColor | 若节点是输入框,表示占位文本背景颜色 |
zIndex | number | | 节点的层级,用于确定节点的渲染顺序。 |
textFontSize | number | 若节点为文本,则为文字字号 |
imageOpacity | number | 若节点是图片,表示图片不透明度,范围0~1 |
- Source
PackedNodeEvent
打包后的节点事件
| Name | Type | Description |
|---|---|---|
onPress | boolean | 是否监听当节点被按下时,触发的事件 |
onRelease | boolean | 是否监听当节点被松开时,触发的事件 |
onFocus | boolean | 是否监听当节点为输入框,聚焦时触发的事件 |
onBlur | boolean | 是否监听当节点为输入框,失去焦点时触发的事件 |
- Source
EntityNodeEvent
玩家节点事件
| Name | Type | Description |
|---|---|---|
onPress | Array.<ClientEvent> | 当节点被按下时,触发的事件 |
onRelease | Array.<ClientEvent> | 当节点被松开时,触发的事件 |
onFocus | Array.<ClientEvent> | 当节点为输入框,聚焦时触发的事件 |
onBlur | Array.<ClientEvent> | 当节点为输入框,失去焦点时触发的事件 |
- Source
EntityClientEvent
玩家客户端事件
- Map.<number, EntityNodeEvent>
- Source
ClientEvent
客户端事件
| Name | Type | Description |
|---|---|---|
handler | EventCallBack | 事件监听回调函数 |
maxTimes | number | 最大触发次数 |
times | number | 当前已触发次数 |
- Source
PackedClientEvent
当节点事件被触发时,发送到服务端的数据
| Name | Type | Attributes | Description |
|---|---|---|---|
protocols | "triggeredEvent" | 事件协议,触发事件的协议为 | |
node | PackedNode | <nullable> | 节点 |
eventName | EventName | 触发的事件类型 |
- Source
PackedData
打包后的数据,用于发送给客户端
要求有protocols属性指定协议
- PackedNode |
PackedClientEvent
- Source
EventCallBack(target, entity) → {void}
事件回调函数
| Name | Type | Description |
|---|---|---|
target | PackedNode | 目标节点 |
entity | GameEntity | 对应玩家 |
- Source
- Type:
- void
PackedNode
打包后的节点
| Name | Type | Attributes | Description |
|---|---|---|---|
protocols | "renderMessage" | | 事件协议,打包节点所需的协议只有 | |
id | number | 节点序号 | |
name | string | <nullable> | 节点名称,只在 |
data | object | <nullable> | 节点自定义数量,只在 |
style | NodeStyle | <nullable> | 节点样式,只在 |
content | string | <nullable> | 节点内容,只在 |
pointerEventBehavior | number | <nullable> | 界面元素对指针事件的行为方式,只在 |
autoResize | string | <nullable> | 节点自动调整尺寸的方式,只在 |
visible | boolean | <nullable> | 节点的可见性,只在 |
placeholder | string | <nullable> | 节点占位文本内容,只在 |
size | Coord2 | <nullable> | 节点大小,只在 |
position | Coord2 | <nullable> | 节点位置,只在 |
anchor | Vector2 | <nullable> | 节点锚点,只在 |
parent | number | <nullable> | 父节点id |
childern | Array.<PackedNode> | <nullable> | 子节点,只在 |
type | NodeType | <nullable> | 节点类型,只在 |
events | PackedNodeEvent | <nullable> | 打包后的节点事件 |
- Source
NodeStyle
节点样式
| Name | Type | Description |
|---|---|---|
textXAlignment | string | | 若节点为文本,则为节点的水平对齐方式 |
textYAlignment | string | | 若节点为文本,则为节点的垂直对齐方式 |
textColor | GameRGBColor | 若节点为文本,则为文字颜色 |
backgroundColor | GameRGBAColor | 节点背景颜色 |
placeholderColor | GameRGBAColor | 若节点是输入框,表示占位文本背景颜色 |
zIndex | number | | 节点的层级,用于确定节点的渲染顺序。 |
textFontSize | number | 若节点为文本,则为文字字号 |
imageOpacity | number | 若节点是图片,表示图片不透明度,范围0~1 |
- Source
PackedNodeEvent
打包后的节点事件
| Name | Type | Description |
|---|---|---|
onPress | boolean | 是否监听当节点被按下时,触发的事件 |
onRelease | boolean | 是否监听当节点被松开时,触发的事件 |
onFocus | boolean | 是否监听当节点为输入框,聚焦时触发的事件 |
onBlur | boolean | 是否监听当节点为输入框,失去焦点时触发的事件 |
- Source
EntityNodeEvent
玩家节点事件
| Name | Type | Description |
|---|---|---|
onPress | Array.<ClientEvent> | 当节点被按下时,触发的事件 |
onRelease | Array.<ClientEvent> | 当节点被松开时,触发的事件 |
onFocus | Array.<ClientEvent> | 当节点为输入框,聚焦时触发的事件 |
onBlur | Array.<ClientEvent> | 当节点为输入框,失去焦点时触发的事件 |
- Source
EntityClientEvent
玩家客户端事件
- Map.<number, EntityNodeEvent>
- Source
ClientEvent
客户端事件
| Name | Type | Description |
|---|---|---|
handler | EventCallBack | 事件监听回调函数 |
maxTimes | number | 最大触发次数 |
times | number | 当前已触发次数 |
- Source
PackedClientEvent
当节点事件被触发时,发送到服务端的数据
| Name | Type | Attributes | Description |
|---|---|---|---|
protocols | "triggeredEvent" | 事件协议,触发事件的协议为 | |
node | PackedNode | <nullable> | 节点 |
eventName | EventName | 触发的事件类型 |
- Source
PackedData
打包后的数据,用于发送给客户端
要求有protocols属性指定协议
- PackedNode |
PackedClientEvent
- Source