Jump to content

melonJS es6 module


obiot
 Share

Recommended Posts

Hi Guys,

as part of the 9.0 (master) branch, all classes have been converted to es6, and the build process now generate 3 files :

  • melonjs.js (plain es5 umd bundle)
  • melonjs.min.js  (minified es5 umd bundle)
  • melons-module.js (es6 module)

both the es5 umd bundle and es6 module are now available under our amazon build bucket (click on the latest build version) :

https://melonjs-builds.s3.amazonaws.com/index.html?prefix=artifacts/master/

I haven't yet really tested it to be honest, as I'm still focusing on other features and I haven't really yet converted any example, but It would really be nice to have any external feedback/testing on this one if anyone here wants to be a alpha-beta tester for the es6 module.

the API are still supposed to be backward compatible (inheritance mechanism has not been changed yet to the es6 class inheritance), so using "import * as me from melons-bundle.js" should just be working as previously.

Thanks!

Edited by obiot
Link to comment
Share on other sites

took me a few build to properly fix some remaining internal reference to the me namespace, but since build 2839, even more complex example such as the platform one is working when importing the ES6 module, so it seems that it starts to be stable enough to share and play with.

here is one, for those interested, that does not have any external dependencies (using the latest dev build)

import * as me from "https://melonjs-builds.s3.amazonaws.com/artifacts/master/2839/build/melonjs-module.js";

// upon device ready
me.device.onReady(function () {
    // Initialize the video.
    if (!me.video.init(1218, 562, {scale : "auto"})) {
        alert("Your browser does not support HTML5 canvas.");
        return;
    }

    // add a gray background layer
    me.game.world.addChild(new me.ColorLayer("background", "#202020"));

    // add a text object in the center of the display
    me.game.world.addChild(new me.Text(609, 281, {
        font: "Arial",
        size: 160,
        fillStyle: "#FFFFFF",
        textBaseline : "middle",
        textAlign : "center",
        text : "Hello World !"
    }));
});

 

Edited by obiot
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...