In Processing I got into the habit of using the tabs to split things up and keep it all tidy. I want to do something similar in p5js. If you check the link you can see that in the JS tab I have a huge (and ever expanding) document. I want to take all the ‘classes’ out and give them their own documents so I don’t spend half my life scrolling up and down.
you have to click on the top left arrow icon to expand the files tab & create a new file (I called it ‘test.js’)
you have to make sure to load the resource (javascript file) in your index.html
the order that you load them in should be the order they are executed (so I have to load the file that defines abefore i can reference a in my main script)
I’m designing in my browser and can’t seem to get this working. How can I put classes rather than just variables in a different .js and have them called from the main sketch?
In your HTML (Probably called index.html) document, you should have a line that looks something like <script src="sketch.js"></script>. You can add more files by linking more. Eg.