author suo
  module gameObject { export class GameObjectCollider extends GameObjectRender { /**
         * 在屏幕的哪个格子里
         */ public grid : number [ ] = [ ] ; /**
         * 碰撞器
         */ public colliderAry : FishingJoy . Collider [ ] = [ ] ; /**
         * 是否已经发生碰撞
         */ public isCollided : boolean = false ; /**
         * 是否需要精准碰撞检测
         */ public isAccurateCollider : boolean = false ; public constructor ( ) { super ( ) ; } /**
         * 初始化一次
         */ public loadConfigData ( data ) { for ( let i = 0 ; i < data . colliderAry . length ; i ++ ) { let colliderData = data . colliderAry [ i ] ; let collider = FishingJoy . Collider . creat ( colliderData . posX , colliderData . posY , colliderData . radius ) ; collider . setParent ( this ) ; this . colliderAry . push ( collider ) ; } if ( data . isAccurateCollider ) { this . isAccurateCollider = data . isAccurateCollider ; } } /**
         * 反初始化
         */ public uninitialize ( ) { this . clearGridIndex ( ) ; super . uninitialize ( ) ; } /**
         * 释放
         */ public dispose ( ) { if ( this . colliderAry . length != 0 ) { for ( let i = 0 ; i < this . colliderAry . length ; i ++ ) { this . colliderAry [ i ] . recover ( ) ; } this . colliderAry . length = 0 ; } super . dispose ( ) ; } /**
         * 添加一个屏幕格子坐标
         */ public pushGridIndex ( index ) { if ( this . grid . indexOf ( index ) == - 1 ) { this . grid . push ( index ) ; } } /**
         * 清除屏幕坐标
         */ public clearGridIndex ( ) { if ( this . grid . length != 0 ) { this . grid . length = 0 ; } } /**
         * 是否在该屏幕坐标内
         */ public isExistGrid ( gridIndex ) { return this . grid . indexOf ( gridIndex ) != - 1 ; } /**
         * 是否相交
         */ public static isIntersect ( gameObjA , gameObjB ) { let gridA = gameObjA . grid ; let gridB = gameObjB . grid ; for ( let i = 0 ; i < gridA . length ; i ++ ) { if ( gameObjB . isExistGrid ( gridA [ i ] ) ) { return true ; } } return false ; } } }