Notice that animSheet is defined before the class because otherwise the preloader would not preload the image. I never did come up with a satisfying solution to how using ES6 style classes broke preloading...

Exactly, with impactES6 you must not use ig.module(...).requires(...).defines(...) because it has its own import and definition module.

Class.inheritance(ig.Entity) is a static function which transform current object into an ES6 Class. The purpose to this function is to correctly interpret this.parent(); which is not the case currently. In fact, at this time you are not obligated to use this to extend your ES6 Class with ig.Class but it will surely change in future versions.

That's also why it is currently not possible to work with old impact scripts.

Notice that you need to use Class.inheritance([ig class name]) for impactJS library but with an ES6 Class, you can use the normal way to extend your children classes, like this :

export default class EntityPlayerDog extends EntityPlayer {
...
}

@Joncom : it's a good point you mentioned about the preloader. There must be a way to preload the image even if it's included directly in the class and not outside. I'll think about it

Quote from myvertigo
The purpose to this function is to correctly interpret this.parent(); which is not the case currently. In fact, at this time you are not obligated to use this to extend your ES6 Class with ig.Class but it will surely change in future versions.

Yeah, if the plan is to go the ES6 route, then it probably makes most sense to use the official this.super() instead of this.parent().

there is 3 points to do to make this 100% compatible with old scripts :

- Check and update the Class.inheritance function to correctly interpret all features of an ES5 Class (like: this.parent(...)) and make sure that when you call super.method(...) it will call the ES5 parent which calling his own parent too with this.parent()

- Find a way to correctly preload image. I've started to thinking about this method :

Once all modules are loaded (and executed), then Impact says "OK, I'm done loading, time to start the game."

The reason pre-loading images works in this scenario is because someImage is just a property of an object that gets passed into ig.Entity.extend(). Meaning it executes immediately, and the ig.Image can tell the pre-loader to wait for it to load.

Notice how the class property is defined inside the constructor itself? This would be like defining the property inside an Impact class init function (which also would break pre-loading).

So the reason pre-loading images does not work in this scenario is because someImage will not be defined until after the class is actually constructed (ie. when the entity gets spawned in-game). Therefore the opportunity to pre-load has already passed.

- It now support all ES5 scripts without do anything.Class.inheritance(ig.Entity) has now disappeared because tests have shown that inheritance between ES6 and Impact ES5 Files are made naturally and safely.

So, if you want to inherit with an ES5 file, you just need to write your class like this :

- ES6 Classes have now default properties preloaded
It is an important feature because in ES6, you can't have default properties before it was rendered. And without default properties, you have 2 issues :
--> You can't preload images
--> Inheritance is not render with properties of children
You can correct it now with ig.bindProperties. Let's see how it works :

It's not so complicated when you know how ES6 Classes work.
Do you know React JS, the framework developed by Facebook ? This framework can be written in ES5 and ES6 and it is almost the same way to define default properties on an ES6 Class. It looks like this :