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 'https://esm.run/melonjs@13';
            import { device } from '../melonjs.module.js';
            import onload from './index.js';

            device.onReady(() => {
                onload();
            });
 </script>



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 :