【发布时间】:2020-09-12 20:20:08
【问题描述】:
我创建了一个简单的 Phaser 3 测试应用程序(在 Typescript 中,使用 rollup 进行转换)并使用 Capacitor 在我的 Mac 上将其转换为 iOS 应用程序。
这是应用程序的相关部分:
function preload () {
this.load.audio('boom', ['boom.mp3', 'boom.ogg', './boom-44100.ogg', './boom-44100.mp3']);
this.load.image('wizball', './wizball.png');
}
function create () {
const image = this.add.image(400, 300, 'wizball').setInteractive();;
this.boom = this.sound.add('boom');
image.on('pointerup', () => {
this.boom.play();
});
}
应用程序显示wizball 的图像,如果单击它,您会听到“砰”的一声。
当我运行它时:
- 使用
npm run watch,在我的Mac 上的浏览器中使用http://localhost:10001,它工作正常; - 通过在我的 Mac 上的浏览器中的
dist/目录中加载index.html,它可以正常工作; - 通过在我的 Mac 或 iPad 上加载 https://garion.org/soundtest-ts/,它可以正常工作;
- 但是当我在 Xcode 中使用 Capacitor 构建 iOS 应用时,单击图像根本没有声音。
这些是生成 iOS 应用程序的步骤:
npm i
npm run watch
npx cap add ios
npx cap copy ios
npx cap open ios
Xcode 中的控制台日志显示如下错误:
Error: There is no audio asset with key "boom" in the audio cache
⚡️ URL: capacitor://localhost/game.js
我觉得这很奇怪,因为可以很好地找到图像资源。在 ios/App/public/ 目录中,boom.mp3 和 wizball.png 都存在。
我已将完整代码以及重现步骤放在这里:https://github.com/joostvunderink/soundtest 您需要安装节点 10+ 和 Xcode(至少配置一个虚拟设备)来构建 iOS 应用程序。
我忽略了什么?
【问题讨论】:
标签: javascript ios typescript phaser-framework capacitor