Hi
I need make a colission in AS3, i’m using hitTest in a movieclip(cube_mc) and when this movieclip beat in the other movieclip(cube2_mc), cube2_mc must to move, like in a collision.
Here’s my example code:
import flash.events.Event;
cube_mc.addEventListener(MouseEvent.MOUSE_UP, dragMC);
cube_mc.addEventListener(MouseEvent.MOUSE_DOWN, dragMC);
cube_mc.addEventListener(Event.ENTER_FRAME, hitMC);
cube_mc.buttonMode = true;
cube_mc.mouseEnabled = true;
cube_mc.mouseChildren = false;
cube_mc.collision = 0;
cube2_mc.collision = 0;
cube_mc.mass = 1;
cube2_mc.mass = 0.7;
function dragMC(e:MouseEvent):void{
switch(e.type){
case "mouseDown":
cube_mc.startDrag();
break;
case "mouseUp":
cube_mc.stopDrag();
break;
}
}
function hitMC(e:Event):void{
if(cube_mc.hitTestObject(cube2_mc)){
hit_txt.text = "HIT";
} else {
hit_txt.text = "";
}
}
Thanks
:joker: