SceneContext

SceneContext

new SceneContext(id)

场景上下文对象

Source:
Parameters:
Name Type Description
id string

场景文件ID

Members

actors :SceneActorList

场景角色管理器

Source:
Type:

animFrame :number

场景图块动画帧计数

Source:
Type:
  • number

animInterval :number

场景图块动画播放间隔

Source:
Type:
  • number

animations :SceneAnimationList

场景动画管理器

Source:
Type:

convert :function

场景转换图块坐标到像素坐标方法

Source:
Type:
  • function

convert2f :function

场景转换图块坐标到像素坐标方法(浮点参数版本)

Source:
Type:
  • function

createClosureMethods

创建闭包方法

Source:

data :Object

场景数据

Source:
Type:

elapsed :number

场景图块动画已播放时间

Source:
Type:
  • number

emitters :SceneParticleEmitterList

场景粒子发射器管理器

Source:
Type:

enabled :boolean

启用状态

Source:
Type:
  • boolean

events :Object

场景事件映射表

Source:
Type:

height :number

场景高度(0-512)

Source:
Type:
  • number

id :string

场景文件ID

Source:
Type:
  • string

idMap :Object

ID->场景对象映射表

Source:
Type:

lights :SceneLightManager

场景光源管理器

Source:
Type:

maxColliderHalf :number

最大的角色碰撞器半径

Source:
Type:
  • number

maxGridCellSize :number

最大的网格分区大小

Source:
Type:
  • number

objects :Array.<Object>

场景对象数据列表

Source:
Type:

obstacles :SceneObstacleArray

场景障碍数据

Source:
Type:

parallaxes :SceneParallaxManager

场景视差图管理器

Source:
Type:

promise :Promise.<SceneContext>

场景加载数据Promise对象

Source:
Type:

regions :SceneRegionList

场景区域管理器

Source:
Type:

renderers :ModuleList

场景渲染器模块列表

Source:
Type:

script :Script

场景脚本管理器

Source:
Type:

subscenes :Array.<Object>

子场景列表

Source:
Type:

terrainObstacles :Uint8Array

场景地形障碍数据(地面:0, 水面:1, 墙块: 2)

Source:
Type:
  • Uint8Array

terrains :SceneTerrainArray

场景地形数据(地面:0, 水面:1, 墙块: 2)

Source:
Type:

tileHeight :number

场景图块高度(16-256)

Source:
Type:
  • number

tileWidth :number

场景图块宽度(16-256)

Source:
Type:
  • number

triggers :SceneTriggerList

场景触发器管理器

Source:
Type:

updaters :ModuleList

场景更新器模块列表

Source:
Type:

width :number

场景宽度(0-512)

Source:
Type:
  • number

Methods

callEvent(type) → {EventHandler|undefined}

调用场景事件

Source:
Parameters:
Name Type Description
type string

场景事件类型

Returns:
Type:
EventHandler | undefined

destroy()

销毁场景上下文

Source:

emit(type)

调用场景事件和脚本

Source:
Parameters:
Name Type Description
type string

场景事件类型

getActor($) → {Actor|undefined}

获取场景指定区域中的角色

Source:
Parameters:
Name Type Attributes Description
$ Object
$.x number

选择区域中心X

$.y number

选择区域中心Y

$.area string <optional>

选择区域

$.size number <optional>

正方形区域边长

$.radius number <optional>

圆形区域半径

$.selector string <optional>

选择器

$.teamId string <optional>

选择器队伍ID

$.condition string <optional>

条件

$.attribute string <optional>

属性键

$.divisor string <optional>

除数属性键

$.activation string <optional>

激活状态条件

$.exclusionActor Actor | null <optional>

排除角色

$.exclusionTeamId string <optional>

排除队伍ID

Returns:
Type:
Actor | undefined

目标角色

getMultipleActors($) → {Actor|undefined}

获取场景指定区域中的多个角色

Source:
Parameters:
Name Type Attributes Description
$ Object
$.x number

选择区域中心X

$.y number

选择区域中心Y

$.area string <optional>

选择区域

$.width number <optional>

矩形区域宽度

$.height number <optional>

矩形区域高度

$.radius number <optional>

圆形区域半径

$.selector string <optional>

选择器

$.teamId string <optional>

选择器队伍ID

$.activation string <optional>

激活状态条件

Returns:
Type:
Actor | undefined

目标角色

getWallPosByRay(sx, sy, dx, dy) → {Object|null}

获取两点之间射线的第一个墙块位置

Source:
Parameters:
Name Type Description
sx number

起点场景X

sy number

起点场景Y

dx number

终点场景X

dy number

终点场景Y

Returns:
Type:
Object | null

isInLineOfSight(sx, sy, dx, dy) → {boolean}

判断起点和终点是否在视线内可见

Source:
Parameters:
Name Type Description
sx number

起点场景X

sy number

起点场景Y

dx number

终点场景X

dy number

终点场景Y

Returns:
Type:
boolean

isInWallBlock(x, y) → {boolean}

判断目标点是否在墙块中

Source:
Parameters:
Name Type Description
x number

场景坐标X

y number

场景坐标Y

Returns:
Type:
boolean

(async) load()

加载场景数据

Source:

loadData(scene)

加载场景数据

Source:
Parameters:
Name Type Description
scene Object

loadObjects(objectList, scenePath) → {Array}

加载初始场景对象

Source:
Parameters:
Name Type Description
objectList Array

场景对象数据列表

scenePath string

场景路径

Returns:
Type:
Array

已创建的场景对象实例列表

(async) loadSubscene(sceneId, offsetXopt, offsetYopt)

加载子场景

Source:
Parameters:
Name Type Attributes Default Description
sceneId string

场景ID

offsetX number <optional>
0

对象偏移X

offsetY number <optional>
0

对象偏移Y

loadTerrainObstacles()

加载地形障碍

Source:

render()

渲染场景画面

Source:

saveData()

保存场景数据

Source:

setAmbientLight(red, green, blue, easingIdopt, durationopt)

设置场景环境光

Source:
Parameters:
Name Type Attributes Description
red number

红[0-255]

green number

绿[0-255]

blue number

蓝[0-255]

easingId number <optional>

过渡曲线ID

duration number <optional>

持续时间(毫秒)

unloadSubscene(sceneId)

卸载子场景

Source:
Parameters:
Name Type Description
sceneId string

场景ID

update(deltaTime)

更新场景模块

Source:
Parameters:
Name Type Description
deltaTime number

时间增量(毫秒)

updateTerrainObstacle(x, y)

更新地形障碍

Source:
Parameters:
Name Type Description
x number

场景X

y number

场景Y