Ok I managed to fix it (it was ridiculously easy), but now i get this error, my issue is that this const is inside one of the statics in here
Uncaught TypeError: can't access property "anims", bomb is undefined
Ok I managed to fix it (it was ridiculously easy), but now i get this error, my issue is that this const is inside one of the statics in here
Uncaught TypeError: can't access property "anims", bomb is undefined
Yeah the way that is structured could use a refactor, I think. For now, you can mutate the scene. When you assign:
const bomb =
change it to:
scene.bomb =
This:
bomb.anims.play("explode", true);
…becomes this:
scene.bomb.anims.play("explode", true);
This is kind of a hacky way to do it, but I would have to dig way into the code to fix it nicely hah.
Well that did not work well, it’s the same error now but with the scene. part, i think it might be better for me to sticking with the copy paste, if this will give me that much of a trouble setting it up.
What line has the error? Is it globalFunctions line 115?
no it’s line 171, the one that makes the bomb play an animation of explosion
Looking at your repo, line 171 is a blank line. I don’t know if I can support the whole development of your app, I was just trying to give you the broad strokes of how you can use classes to reuse your functions. When it comes to porting your code to this new class, you should just work through logically to clear all the undefined stuff. It’s not a bug with how it’s designed, you just have to make sure you’re passing everything properly.
EDIT: it’s line 172 apparently
OK, I’ll try to see if I am able to fix it, my bad for the inconviniences.
Hey, no problem. I just didn’t want to hold you back waiting on me to fix this type of stuff. I don’t fully get what you’re doing in the main class and, most importantly, I don’t know how the game is supposed to work. Like I’ve never seen it running.
Update on this: I did a lot of digging trough some other forums and find the solution: using a (player, star) => {} and a bit of function adjustment it worked perfectly, now I can move on with adding more stages and hopefully learning shaders for palette cycling (Like how the genesis did it)
Ah dw, sometimes I just need some guidance, this helped a lot with the logic of the class!