实现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://www.codercto.com/soft/d/805.html

任正非传

任正非传

孙力科 / 浙江人民出版社 / 2017-5-2 / 39.80

编辑推荐: 超权威、超丰富、超真实的任正非传记 亲述任正非跌宕起伏、传奇精彩的一生 ◆知名财经作家孙力科,历时十年,数十次深入华为,采访华为和任正非历程中各个关键人物,几度增删,创作成此书 ◆全书展现了任正非从出生至今70多年的人生画卷,从入伍到退役进国企,从艰难创业到开拓海外市场,囊括其人生道路上各个关键点,时间跨度之长,内容之丰富,前所未有 ◆迄今为止,任正非一生......一起来看看 《任正非传》 这本书的介绍吧!

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

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

在线XML、JSON转换工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换