SuperAPI AI 工具集

advanced-input

通用与其它

查看项目

更新于 10-16 05:05

技能介绍

用途:处理 Decentraland 场景中的高级输入模式。简单实体点击/悬停建议用 pointerEventsSystem.onPointerDown()(见 add-interactivity);复杂多键或轮询场景用 inputSystem。

主要能力:

  1. PointerLock:用 PointerLock.get(engine.CameraEntity).isPointerLocked 检测锁定,getMutable 可请求或释放;onChange 监听变化。
  2. 光标与世界射线:PrimaryPointerInfo.getOrCreateMutable(engine.RootEntity) 读取 screenCoordinates、screenDelta、worldRayDirection。所有字段可选,需判空;锁定后 screenDelta 仍可用(mouselook 用),移动端恒为 0。
  3. inputSystem:getInputCommand 按实体读取输入命令(含命中数据),IA_ANY 匹配任意键。isTriggered 用于一次性动作,isPressed 用于持续动作。传入 engine.RootEntity 因值为 0 会被当作全局分支,需改用 PointerEventsResult 时间戳水位读根实体输入。
  4. InputModifier:用 InputModifier.create(engine.PlayerEntity, { mode: InputModifier.Mode.Standard({ disableAll: true }) }) 冻结玩家,或用 disableWalk、disableJog、disableRun、disableJump、disableEmote、disableDoubleJump、disableGliding 限制动作;deleteFrom 恢复。仅桌面客户端 2.0 有效。
  5. 平台与语言:@dcl/sdk/platform 的 getPlatform 返回 mobile/desktop/web,未就绪为 null;isMobile 判断移动端。getPlayerLanguage 同步返回 BCP-47 标签,未就绪前为 'en',可用 onPlayerLanguageChanged 监听。
  6. TouchScreenControls:在 engine.RootEntity 上配置移动端原生控件(摇杆、准星、按钮),字段含 touchInputs、mainAction、hideJoystick、hideCrosshair。非移动端无效,仅覆盖输入控件。

限制:部分 API 需特定 SDK 版本;官方长代码与参考文件未在此完整展开。