Here are more notes about working with matter.js manuallyā¦
I figured out how to stop a Physics body from rotatingā¦
Itās⦠inertia: āInfinityā ā¦and itās case sensitive. If an object is scaled, this setting is lost. So, it has to be reset. Hereās an exampleā¦
Matter.Body.scale(red, 1, 1);
Matter.Body.setInertia(red, 'Infinity');
The problem is that scaling is not working as expected. Using āMatter.Body.scaleā changes the size of the collision shape, but Iām not able to scale the āSpriteā (image) to match the change of that shape. I read the documentation, but I didnāt figure out what was wrong.
Hype is already able to scale both the collision shape and the background image, so Iām missing somethingā¦
tomato-physics-test-1.hypetemplate.zip (255.8 KB)
(Pressing a keyboard key will cause the tomato to 64 pixels in diameter.)
However, you can see how Physics freezes if the JavaScript in Test#1 is changed to thisā¦
hypeDocument.setElementProperty(hypeDocument.getElementById('tomato'), 'width', 64, 1, 'linear');
hypeDocument.setElementProperty(hypeDocument.getElementById('tomato'), 'height', 64, 1, 'linear');
So, I think Hype has some pretty creative things going on behind the scenes. Iām not sure, but it seems like Hype is using Matter.js for certain things and Hypeās JavaScript for others.
Also, I tried this⦠Matter.Body.create(red) ā¦to add a red tomato to the scene. I got the following errorā¦
RangeError: Maximum call stack size exceeded.
This stuff is more complicated than I thought.