function ProcessCollisions():void{
//respawn if player died
if(percentHP == 0){
Player.x = _startMarker.x;
Player.y = _startMarker.y;
Gun.x = Player.x;
Gun.y = Player.y - 45;
_boundaries.x = 0;
_boundaries.y = 0;
Player.vy = 0;
currentHP = maxHP;
}
//when Player is Falling
if(Player.vy > 0){
//Otherwise process collisions of boundaires
var collision:Boolean = false;
if(_boundaries.hitTestPoint(Player.x, Player.y, true)){collision = true;}
if(collision == true){
while(collision == true){
Player.y -= 0.1;
Gun.y -= 0.1;
collision = false;
if(_boundaries.hitTestPoint(Player.x, Player.y, true)){collision = true;}
}
trace("Collision is " + collision);
currentHP -= Player.vy * .1
Player.vy = 0;
Gun.vy = 0;
JumpCount = 0;
}
}
}
My Collision processing is above...I have this issue where Collision boolean is constantly returned as false even when I am colliding with an object within _boundaries. It creates a shaking effect onto my player as the while loop constantly pulls the player out of the boundary and the player seemingly falls into it infinitely...Can anyone help with this? Also in a Frame handler called by an Enter Frame Timer I make some more changes to Player.vy, that is included below
function FrameHandler(e:Event):void{
//If Statements to slow character
if(aKeyPressed == false && Player.vx > 0){
Player.vx -= 1
}
else if(dKeyPressed == false && Player.vx < 0){
Player.vx += 1
}
//Gravitates Player
Player.vy += 1.5;
//Controls arrays of bullets for Weapons
//Process Collisions
ProcessCollisions();
//Scroll Stage
scrollStage();
//Attunes for multiple keypresses
MultipleKeypresses();
//Keeps Gun attached to Players Arm
Gun.x = Player.x
Gun.y = Player.y - 45;
if(sKeyPressed){
Gun.y = Player.y - 13;
Gun.x = Player.x + 8;
}
//Checks Health
updateHealthBar()
//move Player and Gun
Gun.y += Player.vy;
Gun.x += Player.vx;
Player.x += Player.vx;
Player.y += Player.vy;
}