Class: CollisionIndex

CollisionIndex

碰撞检测的实现思路: 1. 选择 collsionIndex 1.1 如果 collision scope 是 layer,则在layer上创建 1.2 如果 collision scope 是 map, 则直接使用map的collisionIndex 2. painter中查询collisionIndex中是否有命中 2.1 如果有,则从 elements 中删除当前item 2.2 如果没有,如果需要的,insert到collisionIndex中

Methods

  • collides(box) [source]

  • Test if given box is collided with any other
    Parameter Type Description
    box Array.<Number> [minx, miny, maxx, maxy]
    Returns:
    Boolean:
  • insertBox(box) [source]

  • Insert box in collision index
    Parameter Type Description
    box Array.<Number> [minx, miny, maxx, maxy]
    Returns:
    CollisionIndex: this
  • bulkInsertBox(boxes) [source]

  • Bulk insert boxes in collision index Powered by rbush, it will perform better in subsquent query
    Parameter Type Description
    boxes Array.<Array.<Number>> [[minx, miny, maxx, maxy], ...]
    Returns:
    CollisionIndex: this
  • clear() [source]

  • Clear the collision index
    Returns:
    CollisionIndex: this