Thursday, 13 October 2011

hit test

stage.addEventListener(Event.ENTER_FRAME, checkhit);
//listen to stage on every frame
function checkhit(myevent:Event):void{

cube1.x+=3
cube2.x-=3


if (cube1.hitTestPoint(cube2.x,cube2.y,true)){
// if any of the cubes get hit by the mouse in any direction (x,y) and if mouse hit whole object or reg point
cube2.alpha=.3;
}// if box get hit make box transparent

}

No comments:

Post a Comment