actionscript 3 - How can I get the Hit point on hit test between two dynamically added objects in AS3? -
i want know actual hit point when dash line hitting triangle object.
i using following codes hit between 2 object :
target.hittestobject(border);
where target triangle object , border group placed rectangle stroke solidcolordash.
and using following codes getting hit coordinate :
var x:number = target.x; var y:number = target.y;
and giving x , y coordinate when dash line touching boundary of triangle object want coordinate when dash line touch bitmapdata of triangle object.
so have idea how resolve issue or how hit coordinate.
the following codes solve problem getting real collision:
private var returnvalue:boolean; private var firstpoint:point; private var secondpoint:point; private var firstrectangle:rectangle; private var secondrectangle:rectangle; private var firstobjectbmpdata:bitmapdata; private var secondobjectbmpdata:bitmapdata; private var firstoffsetmatrix:matrix; private var secondoffsetmatrix:matrix; public function testcollision(clip1:displayobjectcontainer, clip2:displayobjectcontainer):boolean { returnvalue = false; firstrectangle = clip1.getbounds(clip1); secondrectangle = clip2.getbounds(clip2); if(secondrectangle.width != 0 && secondrectangle.height != 0 && firstrectangle.width != 0 && firstrectangle.height != 0) { firstobjectbmpdata = new bitmapdata(firstrectangle.width, firstrectangle.height, true, 0); firstobjectbmpdata.draw(clip1); secondobjectbmpdata = new bitmapdata(secondrectangle.width, secondrectangle.height, true, 0); secondobjectbmpdata.draw(clip2); firstpoint = new point(clip1.x, clip1.y) secondpoint = new point(clip2.x, clip2.y) if (firstobjectbmpdata.hittest(firstpoint, 255, secondobjectbmpdata, secondpoint, 255)) { returnvalue = true; } } return returnvalue; }
Comments
Post a Comment