触觉反馈 PRO
Haptics 为脚本暴露 Core Haptics,用于创建比 HapticFeedback 快捷方法更精细的自定义触觉 pattern。
简单的一次性效果可以用 Haptics.transient() 或 Haptics.continuous()。如果需要精确时间线、包络、动态参数、AHAP 数据或可复用 player,则使用 HapticEngine、HapticPattern、HapticEvent 和参数对象。
播放 Pattern
Engine
new HapticEngine(audioSession?)
创建 Core Haptics engine。不传参数时使用默认 engine;传 null 时让 Core Haptics 自行创建 audio session;传 SharedAudioSession 时共享 app 的 audio session。
能力检测
属性
方法
同步方法在 Core Haptics 报错时会抛出 JavaScript Error。Promise 方法会 reject Error。
Events 和 Parameters
常用 event type:
"hapticTransient""hapticContinuous""audioContinuous""audioCustom"
常用 event parameter:
"hapticIntensity""hapticSharpness""attackTime""decayTime""releaseTime""sustained"
AHAP Data
HapticPattern.fromDictionary(dictionary) 接受 AHAP 风格的 dictionary,pattern.exportDictionary() 会返回 pattern 的 dictionary 表示。
