In the swf located here: http://www.fastswf.com/J_HNsL8
I am encoutering a problem with my hitTestPoint collision code below.
var pp:Point = playerVar.localToGlobal(new Point(0,0));
// Collide With Top Side
while (levelVar.wall03.hitTestPoint(pp.x, pp.y + radius-1, true))
{
playerVar.y--;
levelVar.y++;
pp = playerVar.localToGlobal(new Point(0,0));
}
// Collide With Bottom Side
while (levelVar.wall03.hitTestPoint(pp.x, pp.y - radius, true))
{
playerVar.y++;
levelVar.y--;
pp = playerVar.localToGlobal(new Point(0,0));
}
// Collide With Right Side
while (levelVar.wall03.hitTestPoint(pp.x - radius+1, pp.y, true))
{
playerVar.x++;
levelVar.x--;
pp = playerVar.localToGlobal(new Point(0,0));
}
// Collide With Left Side
while (levelVar.wall03.hitTestPoint(pp.x + radius, pp.y, true))
{
playerVar.x--;
levelVar.x++;
pp = playerVar.localToGlobal(new Point(0,0));
}
The player is located inside the levelVar so what should happen is that when the player hits the wall it simply sends the player and the wall away from each other until they are no longer touching. In the swf you’ll notice this works fine for the top of the wall03 but for the other sides it jitters back and forth. Anyone know why this is happening or how to fix it?
Use the arrow keys or wasd to move