自己看源代碼不就好了和我想得一樣,就是循環(huán)判斷,比大小確定範(fàn)圍,直到找到爲(wèi)止。想要實現(xiàn)mouseover啥的,自己照著_fireEvent調(diào)用_getTargetOnHitEvent即可/***????????????????????????????**@param{Object}e?????*@param{String}sType?????,mouse????????????*@param{Number}nX???????????*@param{Number}nY???????????*@return{Boolean}????????????????*@private*/_fireEvent:function(e,sType,nX,nY){varoDisplayObject=null;varbIsNotStoppedBubbling=true;//???????????????????????????????????????if(sType!=="mousemove"&&!collie.Renderer.isStopEvent(sType)){varaDisplayObjects=this._oLayer.getChildren();oDisplayObject=this._getTargetOnHitEvent(aDisplayObjects,nX,nY);//mousedown??????????if(oDisplayObject){bIsNotStoppedBubbling=this._bubbleEvent(oDisplayObject,sType,e,nX,nY);if(sType==="mousedown"){this._setMousedownObject(oDisplayObject);}if(sType==="mouseup"){this._unsetMousedownObject(oDisplayObject);}}}//mouseup???????????if(sType==="mouseup"&&this._getMousedownObject()!==null){oDisplayObject=this._getMousedownObject();this._bubbleEvent(oDisplayObject,sType,e,nX,nY);this._unsetMousedownObject(oDisplayObject);}/***click???,????????touchstart,touchend???????????????????click????????d*@namecollie.Layer#click*@event*@param{Object}htEvent*@param{collie.DisplayObject}htEvent.displayObject????*@param{HTMLEvent}htEvent.event?????*@param{Number}htEvent.x??x??*@param{Number}htEvent.y??y??*//***mousedown???,????????touchstart????????.*@namecollie.Layer#mousedown*@event*@param{Object}htEvent*@param{collie.DisplayObject}htEvent.displayObject????*@param{HTMLEvent}htEvent.event?????*@param{Number}htEvent.x??x??*@param{Number}htEvent.y??y??*//***mouseup???,????????touchend????????.*@namecollie.Layer#mouseup*@event*@param{Object}htEvent*@param{collie.DisplayObject}htEvent.displayObject????*@param{HTMLEvent}htEvent.event?????*@param{Number}htEvent.x??x??*@param{Number}htEvent.y??y??*//***mousemove???,????????touchmove????????.*@namecollie.Layer#mouseup*@event*@param{Object}htEvent*@param{collie.DisplayObject}htEvent.displayObject????*@param{HTMLEvent}htEvent.event?????*@param{Number}htEvent.x??x??*@param{Number}htEvent.y??y??*/if(bIsNotStoppedBubbling){//stop??Layer???????????this._oLayer.fireEvent(sType,{event:e,displayObject:oDisplayObject,x:nX,y:nY});}return!!oDisplayObject;},/***?????????*-????????????????*@private*@param{Array|collie.DisplayObject}vDisplayObject*@param{Number}nX?????x??*@param{Number}nY?????y??*@return{collie.DisplayObject|Boolean}*/_getTargetOnHitEvent:function(vDisplayObject,nX,nY){varoTargetObject=null;if(vDisplayObjectinstanceofArray){for(vari=vDisplayObject.length-1;i>=0;i--){//????if(vDisplayObject[i].hasChild()){oTargetObject=this._getTargetOnHitEvent(vDisplayObject[i].getChildren(),nX,nY);//??????if(oTargetObject){returnoTargetObject;}}//???oTargetObject=this._getTargetOnHitEvent(vDisplayObject[i],nX,nY);//??????if(oTargetObject){returnoTargetObject;}}}else{returnthis._isPointInDisplayObjectBoundary(vDisplayObject,nX,nY)?vDisplayObject:false;}},/***DisplayObject????PointX,PointY????????**@private*@param{collie.DisplayObject}oDisplayObject*@param{Number}nPointX??????X??*@param{Number}nPointY??????Y??*@return{Boolean}?????true*/_isPointInDisplayObjectBoundary:function(oDisplayObject,nPointX,nPointY){//?????????????????????if(!oDisplayObject._htOption.useEvent||!oDisplayObject._htOption.visible||!oDisplayObject._htOption.width||!oDisplayObject._htOption.height||(oDisplayObject._htOption.useEvent==="auto"&&!oDisplayObject.hasAttachedHandler())){returnfalse;}varhtHitArea=oDisplayObject.getHitAreaBoundary();//??????????if(htHitArea.left<=nPointX&&nPointX<=htHitArea.right&&htHitArea.top<=nPointY&&nPointY<=htHitArea.bottom){//hitArea??????????????if(!oDisplayObject._htOption.hitArea){returntrue;}else{varhtPos=oDisplayObject.getRelatedPosition();//??Point????????nPointX-=htPos.x;nPointY-=htPos.y;//transform??varaHitArea=oDisplayObject._htOption.hitArea;aHitArea=collie.Transform.points(oDisplayObject,aHitArea);returnthis._isPointInPolygon(aHitArea,nPointX,nPointY);}}returnfalse;},