美文网首页
h5转盘游戏

h5转盘游戏

作者: 杰森999 | 来源:发表于2017-08-07 14:19 被阅读0次
<html lang="en">
<head>
<meta charset="UTF-8">
<style type="text/css">
*{
    margin:0;
    padding:0;
}
body{
    background:#666;
}
table{
    background:#666;
    margin:30px auto;
}
table tr td{
    width:110px;
    height:110px;
}
#btn{
    width:150px;
    height:40px;
    line-height:40px;
    display:inline-block;
    color:#fff;
    font-family:"Microsoft Yahei";
    background-color:rgb(106,38,19);
    position:relative;
    border-radius:3px;
    cursor:pointer;
    top:100px;
}
#btn:hover{
    background-color:#481305;
}
.tar{
    border:4px solid #660066;
    width:108px;
    height:108px;
    position:absolute;
    top:0;
    left:0;
}
.Img{
    width:120px;
    height:160px;
    position:absolute;
    left:365px;
    top:10px;
    border:1px solid #666;
    border-radius:5px;
    background:url("images/mv.jpg");
    background-size:cover;
    margin-left:-150px;
}
</style>
</head>
<body>
//表格布局
<table border="0" cellpadding="0" cellspacing="1">
    <tr>
        <td id="td0" style="background:url(images/0.png);background-size:cover;"></td>
        <td id="td1" style="background:url(images/1.png);background-size:cover;"></td>
        <td id="td2" style="background:url(images/2.png);background-size:cover;"></td>
        <td id="td3" style="background:url(images/3.png);background-size:cover;"></td>
        <td id="td4" style="background:url(images/4.png);background-size:cover;"></td>
        <td id="td5" style="background:url(images/5.png);background-size:cover;"></td>
        <td id="td6" style="background:url(images/6.png);background-size:cover;"></td>
    </tr>
    <tr>
        <td id="td19" style="background:url(images/19.png);background-size:cover;"></td>
        <td colspan="5" rowspan="3" style="background:#66cc33;text-align:center;position:relative;">
            <div id="btn" >开始抽奖</div>
            
        </td>
        <td id="td7" style="background:url(images/7.png);background-size:cover;"></td>
    </tr>
    <tr>
        <td id="td18" style="background:url(images/18.png);background-size:cover;"></td>
        <td id="td8" style="background:url(images/8.png);background-size:cover;"></td>
    </tr>
    <tr>
        <td id="td17" style="background:url(images/17.png);background-size:cover;"></td>
        <td id="td9" style="background:url(images/9.png);background-size:cover;"></td>
    </tr>
    <tr>
        <td id="td16" style="background:url(images/16.png);background-size:cover;"></td>
        <td id="td15" style="background:url(images/15.png);background-size:cover;"></td>
        <td id="td14" style="background:url(images/14.png);background-size:cover;"></td>
        <td id="td13" style="background:url(images/13.png);background-size:cover;"></td>
        <td id="td12" style="background:url(images/12.png);background-size:cover;"></td>
        <td id="td11" style="background:url(images/11.png);background-size:cover;"></td>
        <td id="td10" style="background:url(images/10.png);background-size:cover;"></td>
    </tr>
</table>

<div class="tar"></div>

<script src="js/jquery-1.11.1.min.js"></script>
<script type="text/javascript">
    var n=0;
    change(0,0); //初始化函数,让tar处于第一个位置

    function change(i,time){
        var $tar = $('div.tar'); //获取tar
        var offset = $('#td'+(i%20)).offset(); //让tar的位置跟表格中的某一个框相同
        $tar.animate({top:offset.top-2,left:offset.left-2},time); //确定tar的位置
        n = i;  //储存当前的i
    }
    
    var num = 0;
    function move(){
        var randomNumber = Math.random(10)*20;//随机生成0-20之间的数字
        randomNumber = Math.ceil(randomNumber)+50;//加上一个50的基数,增加转的圈数
        num = randomNumber; //储存当前随机数
        var m = n;  //把之前储存的n给到m
        for(var i=m;i<randomNumber+m;i++){ //i=m,下一次点击开始按钮,tar就不会又从第一个位置开始跑,同时随机数也要加上m.
            change(i,50); //调用
        }
    }
        
        

    
    window.onload = function(){  //dom节点加载完成时给予开始按钮点击事件,
        btn.onclick = function(){
            move(); //调用
            btn.onclick = '';    //取消点击事件
        }
    }


    var t = 0;
    var btn = document.getElementById('btn');  //获取开始按钮
        setInterval(function(){
            t++;
            if(t%(Math.ceil((num*50/1000)+1))==0){  //  num*50/1000等于转动一次的时间,表示要每过这个时间才能点击开始按钮一次。
                btn.onclick = function(){
                move();
                console.log('执行');
                btn.onclick = '';
                console.log(Math.ceil((num*50/1000)+1)) 
            }
                t = 0;
            }
    },1000)

</script>
</body>
</html>```

相关文章

  • h5转盘游戏

  • 转盘游戏

    Document *{margin: 0;padding: 0;}p{te...

  • 转盘游戏

    暂缺

  • 大转盘H5游戏的优点

    不论是线上还是线下的活动方案和模式越来越多,不过大转盘抽奖依旧是使用率最高的游戏模式。越来越多的电商、银行等主流行...

  • 公司要求写5个h5小游戏

    做iOS开发,公司要求写5个h5小游戏,其中一个就是我们所熟悉的大转盘。 一开始觉得很简单的一个小游戏,但完成了两...

  • 转转盘游戏

    转转盘游戏现在是我们班上最火热的游戏,一开始是我们画一个转盘,在上面写满字,一个人用笔在上面转,还有一个玩的人就很...

  • 转盘游戏改变了 作者:燕爱

    简书平台转盘游戏改版了。 以前转盘游戏有广告,每转一次都要看二十几秒的广告,才能得到加成点数。 转盘加了广告后,让...

  • H5抽奖转盘

    JS引用 jquery-3.2.1.min.jsjQueryRotate.2.2.js 效果图 HTML CSS JS

  • 高防CDN怎样帮助H5游戏公司有效的解决困扰

    cc攻击会对H5游戏造成什么影响,应该如何来防护cc攻击? CC攻击是H5游戏常见的攻击类型,而H5游戏遭受CC攻...

  • H5游戏高防解决方案有哪些?

    cc攻击会对H5游戏造成什么影响,应该如何来防护cc攻击? CC攻击是H5游戏常见的攻击类型,而H5游戏遭受CC攻...

网友评论

      本文标题:h5转盘游戏

      本文链接:https://www.haomeiwen.com/subject/hrailxtx.html