My instance variable (esk) can not move down past where the wall array ends on the bottom. The top works fine! I don't know what's wrong here, hes colliding with nothing beside this wall all the way to the middle of the level.Code:private function onEnter( e:Event ) { checkCollisions(); } private function checkCollisions() { var leftSideWall:int; var rightSideWall:int; var topSideWall:int; var bottomSideWall:int; var leftRightBuffer:int = 2; var topBottomBuffer:int = 2; var leftSideesk:int = esk.x - esk.width/2; var rightSideesk:int = esk.x + esk.width/2; var topSideesk:int = esk.y; var bottomSideesk:int = esk.y; for( var i:int = 0; i < walls.length; i++ ) { leftSideWall = walls[i].x - walls[i].width/2; rightSideWall = walls[i].x + walls[i].width/2; topSideWall = walls[i].y - walls[i].height/2; bottomSideWall = walls[i].y + walls[i].height/2; if( ( rightSideesk >= leftSideWall ) && ( leftSideesk <= rightSideWall ) ) { if( ( bottomSideesk <= topSideWall ) && ( bottomSideesk + esk.dy >= topSideWall) ) { trace("hittop"); esk.y = topSideWall - topBottombuffer; esk.HITTOP = true; break; } else if( ( topSideesk >= bottomSideWall ) && (topSideesk - esk.dy >= bottomSideWall ) ) { trace("hitbot"); esk.y = bottomSideWall + esk.height/2 + topBottombuffer; esk.HITBOTTOM = true; break; } } else { esk.HITTOP = false; esk.HITBOTTOM = false;




Reply With Quote