» Edit Game Info

2 years ago by tobika

Hi there,
I started a project (just for the fun, not productive) in es6 with modules and everything. (mainly some background game logic)

Importing classes with
import Game from './game';

The whole thing is compiled with babel and some sort of babelfy(browserfy) for the modules into one big js file.

Now I want to use the impact engine for this project, ideally imported as a es6 module file so it can interact with all the other game logic I already created.

I succeeded in creating one main.js file with my game main module.
In this file I can import any other es6 modules and use them directly in the impact code.

Now the tricky part.
I can use the impact internal require for impact modules because I still load the impact lib and it's a global variable.
But I can not use the internal require for entities because impact will try to load the actual file at this path. (The idea was that everything is compiled in one file to be able to use the es6 modules)

My solution that works for the moment but everything has to be in one file.
As I said, I succeeded in creating my main game module. If I want I cant create all the entities I need in the same module block by creating the variables inside the module.
var EntityPlayer = ig.Entity.extend({

I tried to create a real entity module in another file but I somehow can't export the right variable to reuse it in the the main game loop.

If I use the js console in the browser I see that the entity module was correctly register withing ig.modules but my main class can't get the 'EntityPlayer' variable because it wasn't required in the right way.

Sorry for this messy post. I was playing around 2 hours yesterday with this problem and just wanted to write about it in case somebody has already experience with it.

In any case, it's just a test project so if there is no real solution, no worries ;-)


2 years ago by tobika

I use a little workaround to be able to continue mixing impact with my es6 modules. I just push them all in a global object attached to the window object.

It's ugly of course but it works ;-)

1 year ago by myvertigo

I know that this post is old, but I've created a plugin of github that allows you to use ES6 features with impactJS

It's actually in a beta version so i don't recommand you to use it with a project already existing.

For more information, take a look at the github page :

1 year ago by dungeonmaster

Well, thanks for the update neverthless :)
Page 1 of 1
« first « previous next › last »

Post Reply

Please login or register to reply.