mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 09:16:01 +08:00
[libgdx] Improved physic constraint rotate().
This commit is contained in:
parent
09e1436504
commit
e17766127d
@ -117,13 +117,12 @@ public class PhysicsConstraint implements Updatable {
|
||||
cy -= y;
|
||||
}
|
||||
|
||||
/** Rotates the physics constraint so next {@link #update(Physics)} forces are applied as if the bone rotated an additional
|
||||
* amount in world space. */
|
||||
public void rotate (float degrees) {
|
||||
/** Rotates the physics constraint so next {@link #update(Physics)} forces are applied as if the bone rotated around the
|
||||
* specified point in world space. */
|
||||
public void rotate (float x, float y, float degrees) {
|
||||
float r = degrees * degRad, cos = cos(r), sin = sin(r);
|
||||
r = tx * cos - ty * sin;
|
||||
ty = tx * sin + ty * cos;
|
||||
tx = r;
|
||||
float dx = cx - x, dy = cy - y;
|
||||
translate(dx * cos - dy * sin - dx, dx * sin + dy * cos - dy);
|
||||
}
|
||||
|
||||
/** Applies the constraint to the constrained bones. */
|
||||
|
||||
@ -810,11 +810,11 @@ public class Skeleton {
|
||||
((PhysicsConstraint)physicsConstraints[i]).translate(x, y);
|
||||
}
|
||||
|
||||
/** Calls {@link PhysicsConstraint#rotate(float)} for each physics constraint. */
|
||||
public void physicsRotate (float degrees) {
|
||||
/** Calls {@link PhysicsConstraint#rotate(float, float, float)} for each physics constraint. */
|
||||
public void physicsRotate (float x, float y, float degrees) {
|
||||
Object[] physicsConstraints = this.physicsConstraints.items;
|
||||
for (int i = 0, n = this.physicsConstraints.size; i < n; i++)
|
||||
((PhysicsConstraint)physicsConstraints[i]).rotate(degrees);
|
||||
((PhysicsConstraint)physicsConstraints[i]).rotate(x, y, degrees);
|
||||
}
|
||||
|
||||
/** Returns the skeleton's time. This is used for time-based manipulations, such as {@link PhysicsConstraint}.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user