当前位置:网站首页>Little girl walking
Little girl walking
2022-04-23 09:05:00 【A blog】
Little girl walking
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title> The little girl is looking for her mother </title>
<style>
*{
margin: 0;
padding: 0;
}
div{
position: absolute;
background-image: url('./image/xnh.png');
height: 106px;
width: 82px;
background-position:0px -212px;
left: 0;
}
</style>
</head>
<body>
<script src="./underscore-min.js"></script>
<script>
// Create constructor
function Gril(){
// Create a div node
this.dom=document.createElement("div");
document.body.appendChild(this.dom); //div Add nodes to body in
var self=this; // Save the current this Point to
this.x=0; // Define the pace from left to right
this.speed=_.random(1,10); // Control your pace
this.state=0; // Defines the movement of the width of the picture
this.ismove=true; // The little girl is walking
this.dom.onclick=function(){ // Action after clicking the picture
if(self.ismove){ // Judge whether you are walking , If so, execute ,if The following sentence
clearInterval(self.timer); // Clear timer
self.ismove=false; // The little girl is not walking
}
else{ // If you're not walking , Is executed
self.move(); // Turn on timer
self.ismove=true;
}
}
this.move() // The default is walking
}
Gril.prototype.move=function(){ // Create prototype objects
var self=this; // Save the current this Point to
this.timer=setInterval(function(){ // Save the timer in timer Properties of the
self.state++; // Increase the movement of the picture
self.x+=_.random(1,10); // Random pace speed
if (self.state>=8) { //if Judge which picture is the first , If it's bigger than the last one , Start with the first one
self.state=0
}
self.dom.style.backgroundPosition=-82*self.state+"px -"+self.state+"px";// Picture location
self.dom.style.left=self.x+"px"; // The speed of walking to the left
}, this.speed*100);
}
//for Loop dynamic creation 10 picture
for (var i = 0; i < 10; i++) {
new Gril();
}
</script>
</body>
</html>
版权声明
本文为[A blog]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230901327211.html
边栏推荐
- Colorui solves the problem of blocking content in bottom navigation
- L2-023 图着色问题 (25 分)(图的遍历)
- Play with binary tree (25 points)
- K210 learning notes (II) serial communication between k210 and stm32
- Brush classic topics
- Thread scheduling (priority)
- Automatic differentiation and higher order derivative in deep learning framework
- 错题汇总1
- Idea package jar file
- OneFlow学习笔记:从Functor到OpExprInterpreter
猜你喜欢
Idea package jar file
L2-024 tribe (25 points) (and check the collection)
Notes d'apprentissage oneflow: de functor à opexprinterpreter
Non duplicate data values of two MySQL query tables
Distributed message oriented middleware framework selection - Digital Architecture Design (7)
企业微信应用授权/静默登录
EmuElec 编译总结
资源打包关系依赖树
【SQL server速成之路】数据库的视图和游标
Pctp test experience sharing
随机推荐
L2-023 图着色问题 (25 分)(图的遍历)
1099 建立二叉搜索树 (30 分)
Thread scheduling (priority)
Wechat: get the owner of a single tag
Go language self-study series | initialization of golang structure
Distributed message oriented middleware framework selection - Digital Architecture Design (7)
Rembg split mask
PLC的点表(寄存器地址和点表定义)破解探测方案--方便工业互联网数据采集
[Luke V0] verification environment 2 - Verification Environment components
调包求得每个样本的k个邻居
Machine learning (VI) -- Bayesian classifier
员工试用期转正申请书(泸州老窖)
Latex paper typesetting operation
653. 两数之和 IV - 输入 BST
Flink reads MySQL and PgSQL at the same time, and the program will get stuck without logs
tsdf +mvs
Share the office and improve the settled experience
MySQL小练习(仅适合初学者,非初学者勿进)
Strength comparison vulnerability of PHP based on hash algorithm
Single chip microcomputer nixie tube stopwatch