melonJS icon indicating copy to clipboard operation
melonJS copied to clipboard

deprecate me.Entity and use me.Renderable together with me.Body for physics & collision

Open obiot opened this issue 5 years ago • 1 comments

for next version of melonJS, the intention is to finally deprecate me.Entity and replace with the use of any me.Renderable to which a user can add a me.Body object for physic & collision.

basically with the new approach, an example would look like the following:

var monsterSprite = me.Sprite.extend({
    init : function () {
        this._super(me.Sprite, "init", [ 0, 0, {
            image: "monster.png"
        }]);

        // add a physic body with a circle as body shape to match the sprite
        this.body = new me.Body(this, new me.Ellipse(6, 6, this.width - 6, this.height - 6));
        // initial velocity
        this.body.vel.set(me.Math.randomFloat(-4, 4), me.Math.randomFloat(-4, 4));
    }
});

we have a countless amount of tickets on me.Entity and issues related to bounds and anchor points (#848, #834, #754, #580, #922) and as the only way to fix it is to rewrite me.Entity or move to something else, with for sure breaking changes, it just makes sense to actually go with the me.Renderable+me.Body route. Furthermore adding a physic Body object to a renderable is also more inline with what the other engines in the industry are doing.

few additions were made in the current 8.0 branch, some further physic changes were planned as well, but as we ended up tackling other issues and focusing on other items like rewriting the WebGL renderer (and adding WebGL2 support), I want to make sure this is properly tested before deprecating anything, so intend is now for next 9.0 version

mentioned related tickets will be closed, in order to regroup everything here.

comments welcome if any (note that the above implementation is already supported, just not thoroughly tested yet)

obiot avatar Jul 22 '20 06:07 obiot

following some related discussion, this one will be postponed to the next 10.0 version. Reason being that this will allow to make of this coming 9.0 a true last (ES5 + Jay Inheritance) legacy version, backward compatible with all previous version.

Starting from 10.0, it will be purely ES6 class definition, inheritance and semantic. No more ES5, No more Jay, and fully deprecated me.Entity class (the API won't be backward compatible anyway)

obiot avatar Sep 16 '21 07:09 obiot