Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(1 edit) (+1)

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)?