Create 2D games in JavaScript, made easier · By Cedric Stoquer
So pixelbox.js comes with a main.js script... how do i use multiple js scripts? Like an enemy.js, player.js, etc? Which I can combine in main.js?
Yes, you can use require:
var player = require('./player');
and in player.js file, define what you want to export:
module.exports = Player;
It's also possible to use the "import" syntax of ES6.
Oh, okay! Thank you!
So in player.js you are exporting a class named Player, right?And are variables defined in player.js accessible in main.js (not just variables in the Player class)?