[libgdx] Fixed slider scale.

This commit is contained in:
Davide Tantillo 2025-06-19 18:14:14 +02:00
parent 1408b21dee
commit 733fa9169c
2 changed files with 8 additions and 6 deletions

View File

@ -430,14 +430,15 @@ public class SkeletonBinary extends SkeletonLoader {
data.local = (nn & 128) != 0; data.local = (nn & 128) != 0;
data.bone = bones[input.readInt(true)]; data.bone = bones[input.readInt(true)];
float offset = input.readFloat(); float offset = input.readFloat();
float propertyScale = 1;
data.property = switch (input.readByte()) { data.property = switch (input.readByte()) {
case 0 -> new FromRotate(); case 0 -> new FromRotate();
case 1 -> { case 1 -> {
offset *= scale; propertyScale = scale;
yield new FromX(); yield new FromX();
} }
case 2 -> { case 2 -> {
offset *= scale; propertyScale = scale;
yield new FromY(); yield new FromY();
} }
case 3 -> new FromScaleX(); case 3 -> new FromScaleX();
@ -445,9 +446,9 @@ public class SkeletonBinary extends SkeletonLoader {
case 5 -> new FromShearY(); case 5 -> new FromShearY();
default -> null; default -> null;
}; };
data.property.offset = offset; data.property.offset = offset * propertyScale;
data.offset = input.readFloat(); data.offset = input.readFloat();
data.scale = input.readFloat(); data.scale = input.readFloat() / propertyScale;
} }
constraints[i] = data; constraints[i] = data;
} }

View File

@ -413,9 +413,10 @@ public class SkeletonJson extends SkeletonLoader {
if (data.bone == null) throw new SerializationException("Slider bone not found: " + boneName); if (data.bone == null) throw new SerializationException("Slider bone not found: " + boneName);
String property = constraintMap.getString("property"); String property = constraintMap.getString("property");
data.property = fromProperty(property); data.property = fromProperty(property);
data.property.offset = constraintMap.getFloat("from", 0) * propertyScale(property, scale); float propertyScale = propertyScale(property, scale);
data.property.offset = constraintMap.getFloat("from", 0) * propertyScale;
data.offset = constraintMap.getFloat("to", 0); data.offset = constraintMap.getFloat("to", 0);
data.scale = constraintMap.getFloat("scale", 1); data.scale = constraintMap.getFloat("scale", 1) / propertyScale;
data.local = constraintMap.getBoolean("local", false); data.local = constraintMap.getBoolean("local", false);
} }