matter.js

How to use a Font Awesome SVG in Matter.js?

我怕爱的太早我们不能终老 提交于 2020-12-23 12:09:36
问题 What I'm trying to do: Use a Font Awesome SVG - sleigh - in matter.js. I've tried this: Matter.Bodies.fromVertices(500, 50 , Matter.Svg.pathToVertices("sleigh.svg")) <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path d="M612.7 350.7l-9.3-7.4c-6.9-5.5-17-4.4-22.5 2.5l-10 12.5c-5.5 6.9-4.4 17 2.5 22.5l9.3 7.4c5.9 4.7 9.2 11.7 9.2 19.2 0 13.6-11 24.6-24.6 24.6H48c-8.8 0-16 7.2-16 16v16c0 8.8 7.2 16 16 16h516c39 0 73.7-29.3 75.9-68.3 1.4-23.8-8.7-46.3-27.2-61zM32 224c0 59.6 40.9

Matter.js calculating force needed

旧城冷巷雨未停 提交于 2020-08-22 09:54:06
问题 Im trying to apply a force to an object. To get it to move in the angle that my mouseposition is generating relative to the object. I have the angle targetAngle = Matter.Vector.angle(myBody.pos, mouse.position); Now I need to apply a force, to get the body to move along that angle. What do I put in the values below for the applyForce method? // applyForce(body, position, force) Body.applyForce(myBody, { x : ??, y : ?? },{ x:??, y: ?? // how do I derive this force?? }); What do I put in the x

Scaling canvas size - Matter.js

妖精的绣舞 提交于 2020-03-05 06:04:39
问题 As per attached image, I'm trying to remove the section that extends beyond the lower horizontal wall scribbled in green. I'm new to matter.js and have issues with the canvas width and height. I've tried several ways but still to no avail. I don't quite grasp how the engine scales and renders itself. It will also get blurry depends on the width and height I set. How can I adjust the canvas correctly to fit the world ? I'm using this mixed shapes example from matter.js demo. //Fetch our canvas

Disabling gravity in Matter.js

a 夏天 提交于 2019-12-05 11:31:21
问题 Is there any way to disable gravity in Matter.js? I want my objects (bodies) to keep their physical abilities (like reaction to collision, restitution, friction etc), but I'd like to prevent the reaction to device's gyro and orientation change. 回答1: Try engine.world.gravity.y = 0; where engine is your engine instance. 来源: https://stackoverflow.com/questions/29466684/disabling-gravity-in-matter-js

Disabling gravity in Matter.js

為{幸葍}努か 提交于 2019-12-04 00:36:26
Is there any way to disable gravity in Matter.js? I want my objects (bodies) to keep their physical abilities (like reaction to collision, restitution, friction etc), but I'd like to prevent the reaction to device's gyro and orientation change. Try engine.world.gravity.y = 0; where engine is your engine instance. 来源: https://stackoverflow.com/questions/29466684/disabling-gravity-in-matter-js