[Extension] arcade-multi-events

There are multiple files; overlap code (scene.onOverlapTile(), sprites.onOverlap(), multiEvents.onOverlap(), etc.) doesn’t work. You can walk through spikes, enemies, enemies don’t get hurt, etc. but spriteEvents extension overlaps work fine. The files that the overlaps are in are Enemies.ts, Player.ts, Levels.ts. When I added the multi events extension the GitHub button in makecode was bugging out so I copy-pasted the file data from pxt.json and put it directly into GitHub; I don’t know if that caused an error? Essentially what happened is I manually added the multiEvents extension to pxt.json in GitHub, and sprite/tile overlaps stopped working.

this was a tough one to figure out! @jwunderl and I debugged it on livestream today: https://www.youtube.com/watch?v=mL_SpqfE91U

the issue is the order of the files in your pxt.json

you need to move the .g.ts and .g.jres files to the top of the files array like this:

3 Likes

This solution works to fix the tile overlaps, but sprites still don’t work… I’ve tested for overlaps in console AND logged the oil hitbox images; images return as {} but it still doesn’t detect sprite overlaps. The link is the same one as before.

Would any content from this extension come to the base editor in the foreseeable future?

1 Like

nope, will probably stay as an extension

2 Likes

once again, this is a problem with the order files are executing.

i recommend you create a new file called spritekinds.ts and put all of your spritekind definitions in that file. then put that file first in the files array in pxt.json

1 Like

wait you can do that. I literally always made init functions (bc of my time with c++ & SDL2) which worked fine. I have an init in my voxel engine and the extension for it. Hmm… is there a way to remove the init() function in my voxel extension, while having the variables exist at the right time? (should I edit pxt.json?)

the files array in pxt.json controls the execution order of the code, except main.ts is always moved to the bottom of the array regardless of where it actually is in the file. in other words, main.ts always runs last.

…that being said, relying on that execution order is a little hacky/fragile. having an init function is better practice!

1 Like