Skip to content

Instantly share code, notes, and snippets.

@learyjk
Created January 4, 2024 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save learyjk/6e32085c8c38fb3e0eb191700eb871a0 to your computer and use it in GitHub Desktop.
Save learyjk/6e32085c8c38fb3e0eb191700eb871a0 to your computer and use it in GitHub Desktop.
How to add images to a Body in matter.js
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