matter模拟一个物体落地自然效果
代码语言:html
所属分类:动画
代码描述:matter模拟一个物体落地自然效果
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> body { margin: 0; } .boops { display: block; margin: 0; overflow: hidden; position: absolute; top: 0; z-index: 1; width: 100vw; } button { background: navy; border: none; border-radius: 0.5rem; color: white; display: block; font-size: 2rem; font-weight: 900; margin: 1rem auto; padding: 0.25rem 1rem; position: relative; z-index: 10; } </style> </head> <body translate="no"> <button id="boop">BOOP</button> <canvas class="boops"></canvas> <script type="text/javascript" src="http://repo.bfw.wiki/bfwrepo/js/matter.js"></script> <script> const world = document.querySelector(".boops"); const { Engine, Render, Runner, World, Bodies } = Matter; function createBall() { const ball = Bodies.circle(Math.round(Math.random() * 1280), -30, 25, { angle: Math.PI * (Math.random() * 2 - 1), friction: 0.001, frictionAir: 0.01, restitution: 0.8, render: { sprite: .........完整代码请登录后点击上方下载按钮下载查看
网友评论0