A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: My instance cant move down past a wall array, so confused!

  1. #1
    Junior Member
    Join Date
    Apr 2013
    Posts
    3

    My instance cant move down past a wall array, so confused!

    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;

  2. #2
    Junior Member
    Join Date
    Apr 2013
    Posts
    3
    Here is the level along with the wall that I mean circled! Don't know if this helps but hey thought it'd be worth a try!Untitled-1.jpg

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center