Lights2d does not work under melonJS 16.1.1

Hello, I am trying to test the lights2d example of melon.js, however I get the following errors when I use ver 16.1.1:

<script type="module">
            //import { device } from '';
            import { device } from '../melonjs.module.js';
            import onload from './index.js';

            device.onReady(() => {

How should I modify the code to make it work again ? Thanks.

Good catch, thank you for reporting this ! will look into it asap

make sure you are also changing this in the index.js file, if you are starting from the light2d example online.

Yes, you are right. I forget to change it in the index.js. However, after I correct this, the light does not follow the pointer, and there are no errors reported in the console.

yes, just noticed the same, I’m looking at it right now.

it’s an issue when only a light object is being added to a scene, as long as you have other objects being updated it will not be an issue.

(still working on fixing it as it should work even with just one Light2d object, stay tuned!)

Thanks, I will wait that in hope.
And I find some other “problems” in the example. I am not sure if they are real problems because I am new to javascript.

  1. For the particles example. The example load a very old version of melonjs and it shows nothing on the screen, just like this.
    屏幕截图 2024-02-12 161615
    And it also won’t work if I change the melon.js to version 16.1.1, because the js files use “me” and “game” variables, which are not defined in version 16.1.1.
  2. For the example, tiled Level loader, I get the following error in the console.

    The plugin “tiled-inflate-plugin” is not compatible with menlo.js 16.1.1
1 Like

for the tiled-inflate-pluging, the issue is the following line:

it should be “melonjs”: “>=15.12” and not “melonjs”: “^15.2.1”

I’ll fix that and republish

Hi, both the Light2d and Tiled Loader example have been updated and are working again with the latest version of melonJS (16.1.3).

note: this might takes a couple of hours to propagate in the CDN and be “visible” for other examples asking for the latest version available.

For the particle example, the thing is that the original author did not update it since a long time, and I did not find the time myself to do it as well. However, it does work with the “included” version of melonJS, and particles are working fine with the latest version of melonJS (see the platformer example when stomping on an enemy)

1 Like

Thanks for your work, I will try them.

Would give me some suggestions about how to learn melon.js ? I find that all the functions of melon.js are packed by js classes, I have to inherit from some classes and overwrite some functions, but how do I konw which class and function I should overwrite. I even can’t find the entry point and figure out the workflow of a melonjs program. :smiling_face_with_tear:

have you seen the “usage” section on our Readme ?

also here there are a few tutorials, the code monkey one is quite good as well as a starting point :