Skip to content

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

@obiot

Description

@obiot

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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions