mirror of
https://github.com/photonstorm/phaser
synced 2024-11-10 15:14:47 +00:00
Merge pull request #6846 from samme/feature/direct-control-friction
Add friction for direct-control bodies
This commit is contained in:
commit
cff438b2f8
2 changed files with 12 additions and 4 deletions
|
@ -357,7 +357,9 @@ var RunImmovableBody1 = function (blockedState)
|
|||
// This is special case code that handles things like vertically moving platforms you can ride
|
||||
if (body1.moves)
|
||||
{
|
||||
body2.y += (body1.y - body1.prev.y) * body1.friction.y;
|
||||
var body1Distance = body1.directControl ? (body1.y - body1.autoFrame.y) : (body1.y - body1.prev.y);
|
||||
|
||||
body2.y += body1Distance * body1.friction.y;
|
||||
body2._dy = body2.y - body2.prev.y;
|
||||
}
|
||||
};
|
||||
|
@ -391,7 +393,9 @@ var RunImmovableBody2 = function (blockedState)
|
|||
// This is special case code that handles things like vertically moving platforms you can ride
|
||||
if (body2.moves)
|
||||
{
|
||||
body1.y += (body2.y - body2.prev.y) * body2.friction.y;
|
||||
var body2Distance = body2.directControl ? (body2.y - body2.autoFrame.y) : (body2.y - body2.prev.y);
|
||||
|
||||
body1.y += body2Distance * body2.friction.y;
|
||||
body1._dy = body1.y - body1.prev.y;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -357,7 +357,9 @@ var RunImmovableBody1 = function (blockedState)
|
|||
// This is special case code that handles things like horizontally moving platforms you can ride
|
||||
if (body1.moves)
|
||||
{
|
||||
body2.x += (body1.x - body1.prev.x) * body1.friction.x;
|
||||
var body1Distance = body1.directControl ? (body1.x - body1.autoFrame.x) : (body1.x - body1.prev.x);
|
||||
|
||||
body2.x += body1Distance * body1.friction.x;
|
||||
body2._dx = body2.x - body2.prev.x;
|
||||
}
|
||||
};
|
||||
|
@ -391,7 +393,9 @@ var RunImmovableBody2 = function (blockedState)
|
|||
// This is special case code that handles things like horizontally moving platforms you can ride
|
||||
if (body2.moves)
|
||||
{
|
||||
body1.x += (body2.x - body2.prev.x) * body2.friction.x;
|
||||
var body2Distance = body2.directControl ? (body2.x - body2.autoFrame.x) : (body2.x - body2.prev.x);
|
||||
|
||||
body1.x += body2Distance * body2.friction.x;
|
||||
body1._dx = body1.x - body1.prev.x;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue