I am trying to establish some boundaries for my platform game. What is happening is when my player hits the "wall" at the right it jumps across the stage to the opposite side. When I hit the left side to begin with, however, it does what it is supposed to and stops at the wall. This is my code:
stage.addEventListener(Event.ENTER_FRAME,handleCollision);
function handleCollision( e:Event ):void{
if(player.hitTestObject(wall2))
{
player.x = stage.x + player.width/2;
}
} stage.addEventListener(Event.ENTER_FRAME,Collision);
function Collision( e:Event ):void{
if(player.hitTestObject(side))
{
player.x = stage.x + player.width/2;
}
} (I know that they do not need to be separated, I just figured I would try it to see if it would work. The one on the top works perfectly, the one on the bottom has something wrong with it) Thanks!