mirror of
https://github.com/wassname/phaser.git
synced 2026-06-27 16:10:15 +08:00
Physics.processRebound now takes Body direction into account, helps with body-body collision bounces (thanks ram64)
Fixed the Example / physics / mass velocity test. Fixed readme typo.
This commit is contained in:
@@ -67,7 +67,7 @@ There is also an [un-official Getting Started Guide](http://www.antonoffplus.com
|
||||
Change Log
|
||||
----------
|
||||
|
||||
Version 1.1.6 - "Shienar" - 24th February 2014
|
||||
Version 1.1.6 - "Shienar" - 24th February 2014 (amended 21:34 GMT)
|
||||
|
||||
New Examples:
|
||||
|
||||
@@ -82,6 +82,8 @@ Updates:
|
||||
|
||||
Bug Fixes:
|
||||
|
||||
* Physics.processRebound now takes Body direction into account, helps with body-body collision bounces (thanks ram64)
|
||||
* Fixed the Example / physics / mass velocity test.
|
||||
* Updated Physics.Body.applyDamping so that velocity is reduced down to zero properly (thanks caezs)
|
||||
* ArcadePhysics.collideSpriteVsTilemapLayer wouldn't call the process or collide callbacks if only 1 tile was involved in the check (thanks mandarinx)
|
||||
* Lots of documentation fixes (thanks nhowell)
|
||||
|
||||
+12
-6
@@ -18,7 +18,7 @@
|
||||
*
|
||||
* Phaser - http://www.phaser.io
|
||||
*
|
||||
* v1.1.6 - Built at: Mon Feb 24 2014 01:27:13
|
||||
* v1.1.6 - Built at: Mon Feb 24 2014 21:36:31
|
||||
*
|
||||
* By Richard Davey http://www.photonstorm.com @photonstorm
|
||||
*
|
||||
@@ -41153,7 +41153,7 @@ Phaser.Physics.Arcade.Body.prototype = {
|
||||
|
||||
if (this.rebound)
|
||||
{
|
||||
this.processRebound(body);
|
||||
this.processRebound(body, response.overlapN);
|
||||
this.reboundCheck(true, true, false);
|
||||
body.reboundCheck(true, true, false);
|
||||
}
|
||||
@@ -41174,7 +41174,7 @@ Phaser.Physics.Arcade.Body.prototype = {
|
||||
|
||||
if (this.rebound)
|
||||
{
|
||||
this.processRebound(body);
|
||||
this.processRebound(body, response.overlapN);
|
||||
this.reboundCheck(true, true, false);
|
||||
body.reboundCheck(true, true, false);
|
||||
}
|
||||
@@ -41257,17 +41257,23 @@ Phaser.Physics.Arcade.Body.prototype = {
|
||||
* @protected
|
||||
* @param {Phaser.Physics.Arcade.Body} body - The Body that collided.
|
||||
*/
|
||||
processRebound: function (body) {
|
||||
processRebound: function (body, overlapN) {
|
||||
|
||||
// Don't rebound again if they've already rebounded in this frame
|
||||
if (!(this._vx <= 0 && this.velocity.x > 0) && !(this._vx >= 0 && this.velocity.x < 0))
|
||||
{
|
||||
this.velocity.x = body.velocity.x - this.velocity.x * this.bounce.x;
|
||||
if (overlapN.x != 0)
|
||||
{
|
||||
this.velocity.x = body.velocity.x - this.velocity.x * this.bounce.x;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(this._vy <= 0 && this.velocity.y > 0) && !(this._vy >= 0 && this.velocity.y < 0))
|
||||
{
|
||||
this.velocity.y = body.velocity.y - this.velocity.y * this.bounce.y;
|
||||
if (overlapN.y != 0)
|
||||
{
|
||||
this.velocity.y = body.velocity.y - this.velocity.y * this.bounce.y;
|
||||
}
|
||||
}
|
||||
|
||||
this.angle = Math.atan2(this.velocity.y, this.velocity.x);
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -15,15 +15,13 @@ function create() {
|
||||
|
||||
aliens = game.add.group();
|
||||
|
||||
game.physics.gravity.y = 100;
|
||||
|
||||
for (var i = 0; i < 50; i++)
|
||||
{
|
||||
var s = aliens.create(game.world.randomX, game.world.randomY, 'baddie');
|
||||
s.name = 'alien' + s;
|
||||
s.body.collideWorldBounds = true;
|
||||
s.body.bounce.setTo(0.8, 0.8);
|
||||
s.body.linearDamping = 0;
|
||||
s.body.linearDamping = 0.1;
|
||||
s.body.minVelocity.setTo(0, 0);
|
||||
s.body.velocity.setTo(10 + Math.random() * 40, 10 + Math.random() * 40);
|
||||
}
|
||||
@@ -32,10 +30,8 @@ function create() {
|
||||
car.name = 'car';
|
||||
car.anchor.setTo(0.5, 0.5);
|
||||
car.body.collideWorldBounds = true;
|
||||
// car.body.bounce.setTo(0.8, 0.8);
|
||||
car.body.allowRotation = true;
|
||||
// car.body.immovable = true;
|
||||
// car.body.minBounceVelocity = 0;
|
||||
car.body.immovable = true;
|
||||
|
||||
}
|
||||
|
||||
@@ -65,17 +61,4 @@ function update() {
|
||||
|
||||
function render() {
|
||||
|
||||
for (var i = 0; i < aliens._container.children.length; i++)
|
||||
{
|
||||
game.debug.renderPolygon(aliens._container.children[i].body.polygons);
|
||||
}
|
||||
|
||||
game.debug.renderPolygon(car.body.polygons);
|
||||
|
||||
// game.debug.renderBodyInfo(aliens._container.children[0], 32, 32);
|
||||
game.debug.renderBodyInfo(aliens._container.children[0], 32, 32);
|
||||
|
||||
// game.debug.renderBodyInfo(car, 16, 24);
|
||||
// game.debug.renderBodyInfo(aliens.getFirstAlive(), 16, 24);
|
||||
|
||||
}
|
||||
|
||||
@@ -652,7 +652,7 @@ Phaser.Physics.Arcade.Body.prototype = {
|
||||
|
||||
if (this.rebound)
|
||||
{
|
||||
this.processRebound(body);
|
||||
this.processRebound(body, response.overlapN);
|
||||
this.reboundCheck(true, true, false);
|
||||
body.reboundCheck(true, true, false);
|
||||
}
|
||||
@@ -673,7 +673,7 @@ Phaser.Physics.Arcade.Body.prototype = {
|
||||
|
||||
if (this.rebound)
|
||||
{
|
||||
this.processRebound(body);
|
||||
this.processRebound(body, response.overlapN);
|
||||
this.reboundCheck(true, true, false);
|
||||
body.reboundCheck(true, true, false);
|
||||
}
|
||||
@@ -756,17 +756,23 @@ Phaser.Physics.Arcade.Body.prototype = {
|
||||
* @protected
|
||||
* @param {Phaser.Physics.Arcade.Body} body - The Body that collided.
|
||||
*/
|
||||
processRebound: function (body) {
|
||||
processRebound: function (body, overlapN) {
|
||||
|
||||
// Don't rebound again if they've already rebounded in this frame
|
||||
if (!(this._vx <= 0 && this.velocity.x > 0) && !(this._vx >= 0 && this.velocity.x < 0))
|
||||
{
|
||||
this.velocity.x = body.velocity.x - this.velocity.x * this.bounce.x;
|
||||
if (overlapN.x != 0)
|
||||
{
|
||||
this.velocity.x = body.velocity.x - this.velocity.x * this.bounce.x;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(this._vy <= 0 && this.velocity.y > 0) && !(this._vy >= 0 && this.velocity.y < 0))
|
||||
{
|
||||
this.velocity.y = body.velocity.y - this.velocity.y * this.bounce.y;
|
||||
if (overlapN.y != 0)
|
||||
{
|
||||
this.velocity.y = body.velocity.y - this.velocity.y * this.bounce.y;
|
||||
}
|
||||
}
|
||||
|
||||
this.angle = Math.atan2(this.velocity.y, this.velocity.x);
|
||||
|
||||
Reference in New Issue
Block a user