Merge pull request #6846 from samme/feature/direct-control-friction

Add friction for direct-control bodies
This commit is contained in:
Zeke Chan 2024-06-29 14:52:02 +08:00 committed by GitHub
commit cff438b2f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 4 deletions

View file

@ -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;
}
};

View file

@ -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;
}
};