오류 : "TILE_SIZE가 정의되지 않았습니다". 월드 클래스의 생성자.요구 사항 파일에서 전역 변수가 정의되지 않았습니다.
내가 사용하려고 :
global.TILE_SIZE = 64;
작동하지만, VAR로를 선언 할 때,하자 또는이 정의되지에서 const. 왜 이런 일이 생길까요?
app.js :
const TILE_SIZE = 64;
let WORLDS = [];
...
let World = require("./World");
...
function init() {
WORLDS[0] = new World(0, [...]);
}
...
init();
World.js :
class World {
constructor(id, boundmap) {
this.id = id;
this.boundmap = boundmap;
this.width = boundmap[0].length * TILE_SIZE;
this.height = boundmap.length * TILE_SIZE;
}
...
}
module.exports = World;