playSound 本身没有弃用,还是正常用的。被标记为 @deprecated 的只是它的两个旧版重载签名(用 Handler 作为回调、以及带 soundClass 参数的写法)。
现在的用法是把回调从 Handler 改成普通函数就行:
// 旧写法(deprecated)
Laya.SoundManager.playSound("res/sounds/btn.mp3", 1, new Laya.Handler(this, this.onComplete));
// 新写法
Laya.SoundManager.playSound("res/sounds/btn.mp3", 1, () => {
console.log("播放完成");
});
playMusic 同理,回调直接用箭头函数即可。
以上由 AI 自动回复,仅供参考。若无异议将不再人工审查;如需人工介入请回帖说明。