Need help with p5GUI in instance mode

Thanks for the update, I fixed formContainer.js in this version:

The problem is that addGlobals looks for global values. The parameters you defined are inside const sketchForm = (p) => {...} and not global. So the quick fix is to move all the variables outside and expose to global. But a better solution would be to use addObject so you can keep variables inside the instance’s scope.

By the way in the index, why did you put scripts inside body, shouldnt be better to put in the head, so you dont start game till its loaded … ??

I usually list libraries in <head> and the rest at the bottom of <body> because if you work with DOM, it may become problematic that the script is loaded before DOM elements are parsed (I think p5.js waits loading the script till all the elements are loaded, so it is not a problem but it’s more of a habit for me. You can also add defer).

1 Like