实现H5中区域判断 King.ShapeTouch

码农软件 · 软件分类 · HTML5开发相关 · 2019-03-07 08:57:58

软件介绍

ShapeTouch

ShapeTouch 该Javascript库用于实现H5中不规则图形按钮可点击区域的判断,特别用于H5游戏中的某些场景。

API 调用接口

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时,该点非透明,点击生效,alpha值大于0,touch为false时,该点透明,alpha为0.
(开发者也可以根据alpha的值自行判断点击是否生效)
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);

本文地址:https://codercto.com/soft/d/805.html

编译原理

编译原理

Alfred V.Aho、Jeffrey D.Ullman、Ravi Sethi / 李建中 / 机械工业出版社 / 2003-8 / 55.00元

《编译原理》作者Alfred V.Aho、Ravi Sethi和Jeffrey D.Ullman是世界著名的计算机 科学家,他们在计算机科学理论、数据库等很多领域都做出了杰出贡献。《编译原理》 是编译领域无可替代的经典著作,被广大计算机专业人士誉为“龙书”。《编译原理》一 直被世界各地的著名高等院校和科研机构(如贝尔实验室、哥伦比亚大学、普 林斯顿大学和斯坦福大学等)广泛用作本科生和研究生编译原理......一起来看看 《编译原理》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

在线进制转换器
在线进制转换器

各进制数互转换器

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具