Created
January 4, 2024 16:25
-
-
Save learyjk/6e32085c8c38fb3e0eb191700eb871a0 to your computer and use it in GitHub Desktop.
How to add images to a Body in matter.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let circle = Bodies.circle(i, 10, 30, { | |
friction: 0.3, | |
frictionAir: 0.00001, | |
restitution: 0.8, | |
render: { | |
sprite: { | |
texture: "your-image-link-here.jpg", | |
}, | |
}, | |
plugin: { | |
wrap: { | |
min: { | |
x: 0, | |
y: 0 | |
}, | |
max: { | |
x: matterContainer.clientWidth, | |
y: matterContainer.clientHeight | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment