html小球跳跃技术原理,弹跳的小球.html · web-project-songyu/原生js小例子 - Gitee.com...
生活随笔
收集整理的这篇文章主要介绍了
html小球跳跃技术原理,弹跳的小球.html · web-project-songyu/原生js小例子 - Gitee.com...
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
Document
#ball {
border-radius: 50%;
position: absolute;
}
var ball = document.getElementById("ball");
var a = { x: 100, y: 50, r: 25, w: 4, h: 5, g: 2, color: "red" }
ball.style.left = a.x + "px";//初始位置
ball.style.top = a.y + "px";
ball.style.width = a.r * 2 + "px";//球的参数
ball.style.height = a.r * 2 + "px";
ball.style.background = a.color;//颜色
var time = setInterval(function () {
a.x += a.w; //移动距离
a.y += a.h;
a.h += a.g; //掉落加速
ball.style.top = a.y + "px";
ball.style.left = a.x + "px";
if (a.y > 500) {//漂移+回弹
a.h = -a.h * 0.8;
}
}, 50);
一键复制
编辑
Web IDE
原始数据
按行查看
历史
总结
以上是生活随笔为你收集整理的html小球跳跃技术原理,弹跳的小球.html · web-project-songyu/原生js小例子 - Gitee.com...的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: android网络质量,基于Androi
- 下一篇: 鸿蒙台湾乌龙茶,郭碧婷生女再闹乌龙?向太