Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private function physicsHandler(e:Event):void
- {
- for (var u:int = 0; u < physObjects.length; u++)
- {
- if(u != 0 && physObjects[u].movable)
- {
- physObjects[u].y += physObjects[u].yVelocity;
- physObjects[u].x += physObjects[u].xVelocity;
- physObjects[u].yVelocity /= 1.2;
- physObjects[u].xVelocity /= 1.2;
- if (physObjects[u].onGround == false && physObjects[u].gravity < 10 && physObjects[u].gravity > -10)
- {
- physObjects[u].gravity += gravPower;
- }
- if (physObjects[u].onGround)
- {
- physObjects[u].gravity = 0;
- physObjects[u].yVelocity = 0;
- }
- physObjects[u].y += physObjects[u].gravity;
- }
- }
- this.y += this.yVelocity;
- this.x += this.xVelocity;
- this.yVelocity /= 1.2;
- this.xVelocity /= 1.2;
- if (this.onGround == false && this.gravity < 10 && this.gravity > -10)
- {
- this.gravity += gravPower;
- }
- if (this.onGround)
- {
- this.gravity = 0;
- this.yVelocity = 0;
- }
- this.y -= this.gravity;
- Body.Update();
- for (var i:int = physObjects.length - 1; i >= 0; i--)
- {
- for (var n:int = 0; n < physObjects.length; n++)
- {
- //trace(physObjects[0].bod.currentBoundsX[1],physObjects[1].bod.currentBoundsX[0]);
- //trace(physObjects[0].bod.currentBoundsX[1] - physObjects[0].bod.currentBoundsX[0],physObjects[1].bod.currentBoundsX[1] - physObjects[1].bod.currentBoundsX[0]);
- //trace(physObjects[1].bod.currentBoundsY[0],physObjects[1].bod.currentBoundsY[1]);
- if(physObjects[i].bod.currentBoundsY[0] >= physObjects[n].bod.currentBoundsY[1] && physObjects[i].bod.currentBoundsY[1] <= physObjects[n].bod.currentBoundsY[0] && physObjects[i].bod.currentBoundsX[0] >= physObjects[n].bod.currentBoundsX[0] && physObjects[i].bod.currentBoundsX[1] <= physObjects[n].bod.currentBoundsX[1])
- {
- physObjects[i].onGround = true
- trace(testNum);
- testNum++;
- }
- else
- {
- physObjects[i].onGround = false;
- }
- if(physObjects[0].bod.currentBoundsY[0] >= physObjects[1].bod.currentBoundsY[1] && physObjects[0].bod.currentBoundsY[1] <= physObjects[1].bod.currentBoundsY[0] && physObjects[0].bod.currentBoundsX[0] >= physObjects[1].bod.currentBoundsX[0] && physObjects[0].bod.currentBoundsX[1] <= physObjects[1].bod.currentBoundsX[1])
- {
- this.onGround = true
- trace(testNum);
- testNum++;
- }
- else
- {
- this.onGround = false;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment