久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      微信小程序刮刮卡的實(shí)現(xiàn)

      微信小程序刮刮卡的實(shí)現(xiàn)

      如何實(shí)現(xiàn)刮刮卡的效果呢?

      思路是:

      1、先將中獎(jiǎng)的圖片或者文字位置和大小確定

      2、開始畫canvas,將位置和大小跟之前中獎(jiǎng)的文案的位置保持一致。

      3、在canvas上覆蓋一層灰色的蒙層,作出刮刮卡未刮之前的效果

      具體代碼如下

      let left=0; this.data.awardCanvas.moveTo(left,0) this.data.awardCanvas.lineTo(left+400,0); this.data.awardCanvas.lineTo(left+400,150); this.data.awardCanvas.lineTo(left,150); this.data.awardCanvas.stroke() this.data.awardCanvas.setFillStyle('#ddd') this.data.awardCanvas.fill() this.data.awardCanvas.draw()

      4、開始做刮刮卡的動(dòng)作,在canvas定義bindtouchstart和bindtouchmove兩個(gè)觸發(fā)的動(dòng)作

      bindtouchstart是開始落手指的第一個(gè)位置,bindtouchmove是手指移動(dòng)的位置

      其中重要一個(gè)canvas屬性是clearRect,清除畫布上的內(nèi)容

      clearRect(清除位置的X坐標(biāo),清除位置的Y坐標(biāo),清除的寬度,清除的高度)

      具體代碼如下:

      this.data.awardCanvas.clearRect(x,y,15,15); this.data.awardCanvas.draw(true)

      具體的代碼在https://github.com/zhaodengping/scratch-mini

      快去試試吧,也許能刮到一等獎(jiǎng)哦~~

      推薦教程:《微信小程序》

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)