栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > Web开发 > Html/CSS > CSS教程

JaveScript 应用之 锅打灰太狼

CSS教程 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

JaveScript 应用之 锅打灰太狼

锅打灰太狼

前两天做了一个小游戏,比上次的寻找徐峥更复杂一点.
游戏内容为灰太狼或小灰灰随机从洞中出现,点击会出现小星星转圈的动画,点击灰太狼加10分,点击小灰灰减10分.
代码中加入了大量注释,便于理解.




    
 
 
 
     #wrap {
  width: 320px;
  height: 480px;
  margin: 20px auto;
  position: relative;
     }

     #content {
  width: 100%;
  height: 100%;
  background: url(imgs/game_bg.jpg);
     }

     #progress {
  position: absolute;
  top: 66px;
  left: 63px;
  width: 180px;
  height: 16px;
  border-radius: 8px;
     }

     #menuGame {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
     }

     #start,
     #introduce {
  color: red;
  font-size: 30px;
     }

     #start {
  position: absolute;
  top: 40%;
  left: 40%;
     }

     #introduce {
  position: absolute;
  top: 50%;
  left: 31%;
     }

     #content img {
  
  
  position: absolute;
     }

     #content img:nth-child(1) {
  bottom: 220px;
  left: 14px;
     }

     #content img:nth-child(2) {
  left: 96px;
  bottom: 265px;
     }

     #content img:nth-child(3) {
  right: 28px;
  bottom: 238px;
     }

     #content img:nth-child(4) {
  left: 12px;
  bottom: 159px;
     }

     #content img:nth-child(5) {
  left: 101px;
  bottom: 188px;
     }

     #content img:nth-child(6) {
  right: 16px;
  bottom: 168px;
     }

     #content img:nth-child(7) {
  left: 28px;
  bottom: 87px;
     }

     #content img:nth-child(8) {
  left: 117px;
  bottom: 107px;
     }

     #content img:nth-child(9) {
  right: 9px;
  bottom: 85px;
     }

     #menuOver {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  display: none;
     }

     #gameOver {
  font-size: 30px;
  line-height: 480px;
  color: red;
  text-align: center;
     }
     #scores{
  
  position: absolute;
  top:0px;
  left: 57px;
  color: white;
     }
 
    

    
 
     
  
  
  
  
  
  
  
  
  
  
     
     
     
     
     
  

开始

操作说明

game over!

0