I would like to know how to include a p5.js sketch in Hype. I already added the libraries in Resources and they are included in the Head of the document.
I can’t find a way to make the function setup work, nor the draw setup inside Hype.
I’d like to apply physics to each of the elements and control it with an iPhone.
This is the sketch of p5.js:
function setup() {
createCanvas(720, 480);
strokeWeight(2);
ellipseMode(RADIUS);
}
I’m not sure if you’ll be able to control the elements on the “canvas” created by the p5 library with Hype’s functionality. You can get a p5 “sketch” to load inside an element in Hype but you won’t be able to apply Hype’s Physics to those elements created by p5.
To me it’s not clear on why you would want to use p5 and Hype in this way. Hype can create ellipses and rectangles and you could definitely control those with Physics.
For clarification on how you would load a p5 “sketch” in an element in Hype run this code on scene load and you’ll see.
Hi DBear, Thank you for your answer.
I did a test following your instructions, but it doesn’t work for me. I’m attaching the Hype document in a ZIp file.
I’m trying to do this test with these basic figures, but my final intention is to use some custom shapes created in p5, apply Physics and test with interactive sounds with p5 Sounds, making the elements have different sounds when they collide with each other.
I think the problem is just that you have not loaded the javascript properly. If you look in the web developer console, you can see a ReferenceError: Can't find variable: p5 error, which indicated p5 has not been loaded.