<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          King.ShapeTouch實(shí)現(xiàn)H5中區(qū)域判斷

          聯(lián)合創(chuàng)作 · 2023-09-19 03:29

          ShapeTouch

          ShapeTouch 該Javascript庫用于實(shí)現(xiàn)H5中不規(guī)則圖形按鈕可點(diǎn)擊區(qū)域的判斷,特別用于H5游戲中的某些場景。

          API 調(diào)用接口

          king.shape.touch(src,x,y,callback)
          king.shape.touchPoint(src,point,callback)

          point對象示例:
          The point object like this:

          {x:9,y:25}

          Return 返回值

          Object {touch: true, alpha: 255} Or Object {touch: false, alpha: 0}

          touch為true時,該點(diǎn)非透明,點(diǎn)擊生效,alpha值大于0,touch為false時,該點(diǎn)透明,alpha為0.
          (開發(fā)者也可以根據(jù)alpha的值自行判斷點(diǎn)擊是否生效)
          The touch is true, the point is not transparent, the alpha value is greater than 0.

          Use 使用

          Html:添加引用后直接使用

          <script type="text/javascript" src="ShapeTouch-min.js"></script>
          <script type="text/javascript">
          (function() {
            king.shape.touch('images/logo.png',20,40,function(result){
              console.log(result);
            });
          });
          </script>

          Cocos creator:將文件放入assets即可,不需require

          this.node.on('touchend', function (event) {
            var touchPoint = event.getLocation();
            var node = event.currentTarget;
            var nodePoint = node.convertToNodeSpace(touchPoint);
            var nodeSrc = node.getComponent(cc.Sprite).spriteFrame.getTexture().url;
            king.shape.touchPoint(nodeSrc,nodePoint,function(result){
              console.log(result);
            });
          }, this);
          瀏覽 9
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          評論
          圖片
          表情
          推薦
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  中文字幕在线观看永久不卡 | 三级影院麻 | 天天影视成人 | 五月丁香婷婷六月 | 97国产超碰在线观看 |