Thursday, November 10, 2011

collision detection






stage.addEventListener(Event.ENTER_FRAME,checkHit);
listen for something is getting hit

function checkHit(myevent:Event):void {
cube1.x+=3
cube2.x-=3

if(cube2.hitTestPoint(cube1.x,cube1.y, true)) {
cube1.alpha=.3;

if cube 2 hits cube 1 then change its alpha by 3
}

}


No comments:

Post a Comment