最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

微信小程序?qū)崿F(xiàn)簡(jiǎn)單的搖骰子游戲

 更新時(shí)間:2021年05月26日 11:14:48   作者:Honey-回憶天明  
這篇文章主要為大家詳細(xì)介紹了微信小程序?qū)崿F(xiàn)簡(jiǎn)單的搖骰子游戲,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了微信小程序?qū)崿F(xiàn)搖骰子游戲的具體代碼,供大家參考,具體內(nèi)容如下

頁(yè)面代碼

<view class='top'>{{txt}}</view>
<view class='point1'>
 <image src='{{one_img}}'></image>
</view>
<view class='point2'>
 <image src='{{two_img}}'></image>
 <image src='{{three_img}}'></image>
</view>
<view class='btn' bindtap='enter'>{{msg}}</view>

樣式代碼

.top{
  width: 220px;
  height: 30px;
  font-size: 25px;
  margin: 20px auto;
}
.point1 image,.point2 image{
  width: 150px;
  height: 150px;
}
.point1 image{
  display: block;
  margin:45px auto;
}
.point2 image{
   margin-top: -20px;
   margin-left: 25px;
}
.btn{
  width:100%;
  height:60px;
  background:green;
  border-radius: 10px;
  line-height: 60px;
  text-align: center;
  font-size: 30px;
  margin-top: 60px;
}

js代碼

//index.js
//獲取應(yīng)用實(shí)例
const app = getApp()

Page({
  data: {
    one_img:'../../image/6-point.png',
    two_img: '../../image/6-point.png',
    three_img: '../../image/6-point.png',
    flag:true,
    timer:null,
    msg:'搖一搖',
    total:0,
    txt:'恭喜你搖到了:0',
    //圖片的素材和效果圖會(huì)發(fā)在最下面
    arr:[
      '../../image/1-point.png',
      '../../image/2-point.png',
      '../../image/3-point.png',
      '../../image/4-point.png',
      '../../image/5-point.png',
      '../../image/6-point.png',
    ]
  },
  enter:function(event){
    let obj = this;
    if(obj.data.flag==true){
       obj.data.timer = setInterval(function () {
        let one = Math.floor(Math.random() * 6);
        let two = Math.floor(Math.random() * 6);
        let three = Math.floor(Math.random() * 6);
        obj.setData({
          one_img: obj.data.arr[one],
          two_img: obj.data.arr[two],
          three_img: obj.data.arr[three],
          flag:false,
          msg:'停止',
          total:one+two+three+3,
         // total:18,
          txt:'',
        })
      }, 50);
    }else{
      clearInterval(obj.data.timer);
      obj.setData({
         //one_img: obj.data.arr[5],
         //two_img: obj.data.arr[5],
         //three_img: obj.data.arr[5],
           msg:'搖一搖',
           flag:true,
           txt:'恭喜你搖到了:'+obj.data.total,
      })
    }
   
  },
  
})

圖片素材和效果圖

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

盐源县| 林甸县| 故城县| 新兴县| 峨眉山市| 阿拉善左旗| 小金县| 察雅县| 海阳市| 淮北市| 大安市| 齐齐哈尔市| 炉霍县| 荆州市| 依兰县| 汾西县| 永寿县| 安阳市| 卓资县| 山丹县| 潮州市| 乌拉特前旗| 天柱县| 防城港市| 常山县| 墨脱县| 西华县| 涞源县| 汉源县| 苏尼特右旗| 临汾市| 社旗县| 岢岚县| 北海市| 锡林浩特市| 宜川县| 哈密市| 溧水县| 晋江市| 新乡县| 临沂市|