github地址:https://github.com/ningbnii/vite2_vue3_phaser_demos
项目演示地址:http://wxbuluo.com/phaser/
项目持续更新中
1、切换路由后,发现update仍在执行。解决方案:在onUnmounted中销毁场景
onUnmounted(() => {
for (let key in game.scene.keys) {
if (game.scene.keys.hasOwnProperty(key)) {
game.scene.stop(key);
game.scene.keys[key] = undefined;
}
}
});
2、发现import test_json from '../../assets/test.json'引入json的方法,有些格式无法解析,使用import.meta.url方式引入则可以
const sea_json = new URL("../../assets/sea_creatures_json.json", import.meta.url).href
3、发现图片放到public/assets/下面更合适,这样引入图片就不用import了