我试图使我的Phaser 3游戏移动友好,我在api中找到了比例管理器方法,但是当我试图将它添加到我的配置中时,我会得到以下错误:
Uncaught TypeError: Cannot read property 'FIT' of undefined
我正在利用webpack进口Phaser,我想知道这是否是问题的一部分?我对Webpack很陌生,但我跟踪了使用它的这个非常棒的教程。
我的配置如下所示:
import Phaser from 'phaser';
import StartSceen from './StartSceen';
import Instructions from './Instructions';
import PreloadScene from './PreloadScene';
import Scene1 from './Scene1';
import Scene2 from './Scene2';
import GameOverScreen from './GameOverScreen';
import WinScreen from './WinScreen';
const gameConfig = {
type: Phaser.AUTO,
domCreateContainer: true,
parent: 'game-container',
width: 800,
height: 600,
scale: {
mode: Phaser.Scale.FIT,
autoCenter: Phaser.Scale.CENTER_BOTH,
},
// StartSceen, PreloadScene,
scene: [StartSceen, Instructions, PreloadScene, Scene1, Scene2, GameOverScreen, WinScreen],
physics: {
default: 'arcade',
arcade: {
gravity: { y: 300 },
debug: false,
},
},
};
export default gameConfig;当上面的几行Phaser.Scale运行良好时,有没有人知道为什么Phaser.AUTO是未定义的?
发布于 2022-08-15 20:41:47
也有同样的问题,但我将Phaser更新为3.55.0版本,它运行良好,CDN:https://cdn.jsdelivr.net/npm/phaser@3.55.0/dist/phaser.js
https://stackoverflow.com/questions/57896210
复制相似问题