javascript解析人体运动

8 篇文章 0 订阅

<html>
 <head>

        <script>
  var xp=0;
  var imgIndex=1;
  var moveTimer;
  function move(){
   xp=xp+20;   //每一次div的位移的辐度
   document.getElementById('red').style.left=xp+'px'; //开始的位置,px像素
   imgIndex=imgIndex==5?1:(imgIndex+1); //图片的数量,结束之后从第一张开始循环;
   document.getElementById('red').className='img'+imgIndex //图片的循环
   if(xp>=1290)
    clearInterval(moveTimer);  //用于限制跑的距离,超出将会被终止;
  }
  window.οnlοad=function(){ moveTimer=setInterval(move,80);}  //移动的速度
  </script>
  <!-- 在一张人体解析图片上,获取每个动作的高和宽以及从最左边到这个动作的距离,每个动作建立坐标; -->
<style> 
.img1{
background:url("ZU.jpg") no-repeat scroll -30px 0 transparent;
width:151px;
height:205px;
}

.img2{
background:url("ZU.jpg") no-repeat scroll -188px 0 transparent;
width:151px;
height:205px;
}

.img3{
background:url("ZU.jpg") no-repeat scroll -332px 0 transparent;
width:151px;
height:205px;
}

.img4{
background:url("ZU.jpg") no-repeat scroll -473px 0 transparent;
width:124px;
height:205px;
}

.img5{
background:url("ZU.jpg") no-repeat scroll -588px 0 transparent;
width:145px;
height:205px;
}
</style>
  
 </head>
 <body>

<div id="red" class="img" style="position:absolute;left:0;top:0"></div> 
<!-- //设置图片的初始位置 -->
    
 </body>
</html>

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值