hitTest
简单2D碰撞检测
Install
You can install it via npm:
npm install hit-test
Use
;
javascript:
Example
矩形 & 矩形
var rect1= x:0 y:0 width:50 height:60 ; var rect2= x:50 y:80 x:100 height:80 ; ifhitTest console; else console;
圆形 & 圆形
var circle1= x:0 y:0 radius:10 ; var circle2= x:50 y:80 radius:15 ; ifhitTest console; else console;
矩形 & 圆形
var rect1= x:0 y:0 width:50 height:60 ; var circle2= x:50 y:80 radius:15 ; ifhitTest console; else console;
矩形(带旋转角) & 圆形
只能判断以矩形中心为旋转中心的情况
var rect1= x:0 y:0 width:50 height:60 rotation:13 //弦度 ; var circle2= x:50 y:80 radius:15 ; ifhitTest console; else console;
多边形 & 多边形
var points1=194212 235170216107136136146196; var points2=250 208 305247402 238 340 150; ifhitTest console; else console;