Handling Collisions?
Currently, I have a very very poor colision system. It's based off 4 points, if they hit an object, it stops me, if they don't, I can move freely. Simple right?
The issue is that these points don't cover my entire player object. I tried using a line, and it tweaked out and made it impossible to walk left (I'm working on my left collider before the rest). I also tried making a for loop that would handle all possible points between 2 given numbers (in this case 0 through -116.5). I don't think I initialized it correctly upon testing so it didn't work.
This is the check if I hit or not. True = hit, false = not hit.
var leftBumping:Boolean = false;
Here are my last 2 efforts:
var leftLine:Shape = new Shape();
leftLine.graphics.lineStyle(1,0x000000,0);
leftLine.graphics.moveTo(-26, 0);
leftLine.graphics.lineTo(-26, -115);
/**var leftBumpPoint:Array = new Array(leftP1, leftP2, leftP3, leftP4, leftP5, leftP6);
var leftP1:Point = new Point(-30, -55);
var leftP2:Point = new Point(-30, 0);
var leftP3:Point = new Point(-30, -25);
var leftP4:Point = new Point(-30, -75);
var leftP5:Point = new Point(-30, -195);
var leftP6:Point = new Point(-30, -116.5);**/
I have leftLine being used right now and it currently doesn't want to work correctly.
And the if/else statement to check:
| if(back.collisions.hitTestPoint(player.x + leftLine.x+1, player.y + leftLine.y+1, true)){ | ||
| leftBumping = true; | ||
| } else { | ||
| leftBumping = false; | ||
| } |
(I have no idea why it's putting that code into a table)
What's a good way to handle this?
