I am having trouble with getting some code dealing with collision detection to work. I have tested to ensure that it does detect the collisions, and it does, however I am unable to get it to work as it just walks through the block. I also tried just taking away -10 from the x value after it collides but it will stay for the first couple of tries then just walk through the block.
private function collisionDetect(evt:Event):void{
if(IMG3.hitTestObject(block)){
if(IMG3.x > block.x){
IMG3.x = block.x-1;
}
}
}
IMG3.x > block.xThis is problematic, unless IMG3's is located at the right edge and block's center is located at the left edge. You need to account for their width, so assuming them both have their center at the left edge, the correct would beIMG3.x + IMG3.width > block.x. - felipemaia