mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-22 10:16:01 +08:00
Support new libgdx JSON stuff. Alpha for slot lines with debug renderer.
This commit is contained in:
parent
e64b3c201a
commit
f55249dcbe
@ -45,8 +45,8 @@ import com.badlogic.gdx.graphics.Color;
|
|||||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
import com.badlogic.gdx.utils.Json;
|
import com.badlogic.gdx.utils.Json;
|
||||||
import com.badlogic.gdx.utils.ObjectMap.Entry;
|
import com.badlogic.gdx.utils.JsonReader;
|
||||||
import com.badlogic.gdx.utils.OrderedMap;
|
import com.badlogic.gdx.utils.JsonValue;
|
||||||
import com.badlogic.gdx.utils.SerializationException;
|
import com.badlogic.gdx.utils.SerializationException;
|
||||||
|
|
||||||
public class SkeletonJson {
|
public class SkeletonJson {
|
||||||
@ -83,68 +83,59 @@ public class SkeletonJson {
|
|||||||
SkeletonData skeletonData = new SkeletonData();
|
SkeletonData skeletonData = new SkeletonData();
|
||||||
skeletonData.setName(file.nameWithoutExtension());
|
skeletonData.setName(file.nameWithoutExtension());
|
||||||
|
|
||||||
OrderedMap<String, ?> root = json.fromJson(OrderedMap.class, file);
|
JsonValue root = new JsonReader().parse(file);
|
||||||
|
|
||||||
// Bones.
|
// Bones.
|
||||||
for (OrderedMap boneMap : (Array<OrderedMap>)root.get("bones")) {
|
for (JsonValue boneMap = root.getChild("bones"); boneMap != null; boneMap = boneMap.next()) {
|
||||||
BoneData parent = null;
|
BoneData parent = null;
|
||||||
String parentName = (String)boneMap.get("parent");
|
String parentName = boneMap.getString("parent", null);
|
||||||
if (parentName != null) {
|
if (parentName != null) {
|
||||||
parent = skeletonData.findBone(parentName);
|
parent = skeletonData.findBone(parentName);
|
||||||
if (parent == null) throw new SerializationException("Parent bone not found: " + parentName);
|
if (parent == null) throw new SerializationException("Parent bone not found: " + parentName);
|
||||||
}
|
}
|
||||||
BoneData boneData = new BoneData((String)boneMap.get("name"), parent);
|
BoneData boneData = new BoneData(boneMap.getString("name"), parent);
|
||||||
boneData.length = getFloat(boneMap, "length", 0) * scale;
|
boneData.length = boneMap.getFloat("length", 0) * scale;
|
||||||
boneData.x = getFloat(boneMap, "x", 0) * scale;
|
boneData.x = boneMap.getFloat("x", 0) * scale;
|
||||||
boneData.y = getFloat(boneMap, "y", 0) * scale;
|
boneData.y = boneMap.getFloat("y", 0) * scale;
|
||||||
boneData.rotation = getFloat(boneMap, "rotation", 0);
|
boneData.rotation = boneMap.getFloat("rotation", 0);
|
||||||
boneData.scaleX = getFloat(boneMap, "scaleX", 1);
|
boneData.scaleX = boneMap.getFloat("scaleX", 1);
|
||||||
boneData.scaleY = getFloat(boneMap, "scaleY", 1);
|
boneData.scaleY = boneMap.getFloat("scaleY", 1);
|
||||||
skeletonData.addBone(boneData);
|
skeletonData.addBone(boneData);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Slots.
|
// Slots.
|
||||||
Array<OrderedMap> slots = (Array<OrderedMap>)root.get("slots");
|
for (JsonValue slotMap = root.getChild("slots"); slotMap != null; slotMap = slotMap.next()) {
|
||||||
if (slots != null) {
|
String slotName = slotMap.getString("name");
|
||||||
for (OrderedMap slotMap : slots) {
|
String boneName = slotMap.getString("bone");
|
||||||
String slotName = (String)slotMap.get("name");
|
|
||||||
String boneName = (String)slotMap.get("bone");
|
|
||||||
BoneData boneData = skeletonData.findBone(boneName);
|
BoneData boneData = skeletonData.findBone(boneName);
|
||||||
if (boneData == null) throw new SerializationException("Slot bone not found: " + boneName);
|
if (boneData == null) throw new SerializationException("Slot bone not found: " + boneName);
|
||||||
SlotData slotData = new SlotData(slotName, boneData);
|
SlotData slotData = new SlotData(slotName, boneData);
|
||||||
|
|
||||||
String color = (String)slotMap.get("color");
|
String color = slotMap.getString("color", null);
|
||||||
if (color != null) slotData.getColor().set(Color.valueOf(color));
|
if (color != null) slotData.getColor().set(Color.valueOf(color));
|
||||||
|
|
||||||
slotData.setAttachmentName((String)slotMap.get("attachment"));
|
slotData.setAttachmentName(slotMap.getString("attachment", null));
|
||||||
|
|
||||||
skeletonData.addSlot(slotData);
|
skeletonData.addSlot(slotData);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Skins.
|
// Skins.
|
||||||
OrderedMap<String, OrderedMap> skinsMap = (OrderedMap)root.get("skins");
|
for (JsonValue skinMap = root.getChild("skins"); skinMap != null; skinMap = skinMap.next()) {
|
||||||
if (skinsMap != null) {
|
Skin skin = new Skin(skinMap.name());
|
||||||
for (Entry<String, OrderedMap> entry : skinsMap.entries()) {
|
for (JsonValue slotEntry = skinMap.child(); slotEntry != null; slotEntry = slotEntry.next()) {
|
||||||
Skin skin = new Skin(entry.key);
|
int slotIndex = skeletonData.findSlotIndex(slotEntry.name());
|
||||||
for (Entry<String, OrderedMap> slotEntry : ((OrderedMap<String, OrderedMap>)entry.value).entries()) {
|
for (JsonValue entry = slotEntry.child(); entry != null; entry = entry.next()) {
|
||||||
int slotIndex = skeletonData.findSlotIndex(slotEntry.key);
|
Attachment attachment = readAttachment(skin, entry.name(), entry);
|
||||||
for (Entry<String, OrderedMap> attachmentEntry : ((OrderedMap<String, OrderedMap>)slotEntry.value).entries()) {
|
if (attachment != null) skin.addAttachment(slotIndex, entry.name(), attachment);
|
||||||
Attachment attachment = readAttachment(skin, attachmentEntry.key, attachmentEntry.value);
|
|
||||||
if (attachment != null) skin.addAttachment(slotIndex, attachmentEntry.key, attachment);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
skeletonData.addSkin(skin);
|
skeletonData.addSkin(skin);
|
||||||
if (skin.name.equals("default")) skeletonData.setDefaultSkin(skin);
|
if (skin.name.equals("default")) skeletonData.setDefaultSkin(skin);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Animations.
|
// Animations.
|
||||||
OrderedMap<String, OrderedMap> animationMap = (OrderedMap)root.get("animations");
|
for (JsonValue animationMap = root.getChild("animations"); animationMap != null; animationMap = animationMap.next())
|
||||||
if (animationMap != null) {
|
readAnimation(animationMap.name(), animationMap, skeletonData);
|
||||||
for (Entry<String, OrderedMap> entry : animationMap.entries())
|
|
||||||
readAnimation(entry.key, entry.value, skeletonData);
|
|
||||||
}
|
|
||||||
|
|
||||||
skeletonData.bones.shrink();
|
skeletonData.bones.shrink();
|
||||||
skeletonData.slots.shrink();
|
skeletonData.slots.shrink();
|
||||||
@ -153,80 +144,55 @@ public class SkeletonJson {
|
|||||||
return skeletonData;
|
return skeletonData;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Attachment readAttachment (Skin skin, String name, OrderedMap map) {
|
private Attachment readAttachment (Skin skin, String name, JsonValue map) {
|
||||||
name = (String)map.get("name", name);
|
name = map.getString("name", name);
|
||||||
|
|
||||||
AttachmentType type = AttachmentType.valueOf((String)map.get("type", AttachmentType.region.name()));
|
AttachmentType type = AttachmentType.valueOf(map.getString("type", AttachmentType.region.name()));
|
||||||
Attachment attachment = attachmentLoader.newAttachment(skin, type, name);
|
Attachment attachment = attachmentLoader.newAttachment(skin, type, name);
|
||||||
|
|
||||||
if (attachment instanceof RegionSequenceAttachment) {
|
if (attachment instanceof RegionSequenceAttachment) {
|
||||||
RegionSequenceAttachment regionSequenceAttachment = (RegionSequenceAttachment)attachment;
|
RegionSequenceAttachment regionSequenceAttachment = (RegionSequenceAttachment)attachment;
|
||||||
|
|
||||||
Float fps = getFloat(map, "fps");
|
float fps = map.getFloat("fps");
|
||||||
if (fps == null) throw new SerializationException("Region sequence attachment missing fps: " + name);
|
|
||||||
regionSequenceAttachment.setFrameTime(fps);
|
regionSequenceAttachment.setFrameTime(fps);
|
||||||
|
|
||||||
String modeString = (String)map.get("mode");
|
String modeString = map.getString("mode");
|
||||||
regionSequenceAttachment.setMode(modeString == null ? Mode.forward : Mode.valueOf(modeString));
|
regionSequenceAttachment.setMode(modeString == null ? Mode.forward : Mode.valueOf(modeString));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attachment instanceof RegionAttachment) {
|
if (attachment instanceof RegionAttachment) {
|
||||||
RegionAttachment regionAttachment = (RegionAttachment)attachment;
|
RegionAttachment regionAttachment = (RegionAttachment)attachment;
|
||||||
regionAttachment.setX(getFloat(map, "x", 0) * scale);
|
regionAttachment.setX(map.getFloat("x", 0) * scale);
|
||||||
regionAttachment.setY(getFloat(map, "y", 0) * scale);
|
regionAttachment.setY(map.getFloat("y", 0) * scale);
|
||||||
regionAttachment.setScaleX(getFloat(map, "scaleX", 1));
|
regionAttachment.setScaleX(map.getFloat("scaleX", 1));
|
||||||
regionAttachment.setScaleY(getFloat(map, "scaleY", 1));
|
regionAttachment.setScaleY(map.getFloat("scaleY", 1));
|
||||||
regionAttachment.setRotation(getFloat(map, "rotation", 0));
|
regionAttachment.setRotation(map.getFloat("rotation", 0));
|
||||||
regionAttachment.setWidth(getFloat(map, "width", 32) * scale);
|
regionAttachment.setWidth(map.getFloat("width", 32) * scale);
|
||||||
regionAttachment.setHeight(getFloat(map, "height", 32) * scale);
|
regionAttachment.setHeight(map.getFloat("height", 32) * scale);
|
||||||
regionAttachment.updateOffset();
|
regionAttachment.updateOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
return attachment;
|
return attachment;
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getFloat (OrderedMap map, String name, float defaultValue) {
|
private void readAnimation (String name, JsonValue map, SkeletonData skeletonData) {
|
||||||
Object value = map.get(name);
|
|
||||||
if (value == null) return defaultValue;
|
|
||||||
if (value instanceof Long) return (Long)value;
|
|
||||||
return (Float)value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private float getFloat (OrderedMap map, String name) {
|
|
||||||
Object value = map.get(name);
|
|
||||||
if (value instanceof Long) return (Long)value;
|
|
||||||
return (Float)value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private float getFloat (Array array, int index) {
|
|
||||||
Object value = array.get(index);
|
|
||||||
if (value instanceof Long) return (Long)value;
|
|
||||||
return (Float)value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void readAnimation (String name, OrderedMap<String, ?> map, SkeletonData skeletonData) {
|
|
||||||
Array<Timeline> timelines = new Array();
|
Array<Timeline> timelines = new Array();
|
||||||
float duration = 0;
|
float duration = 0;
|
||||||
|
|
||||||
OrderedMap<String, ?> bonesMap = (OrderedMap)map.get("bones");
|
for (JsonValue boneMap = map.getChild("bones"); boneMap != null; boneMap = boneMap.next()) {
|
||||||
if (bonesMap != null) {
|
int boneIndex = skeletonData.findBoneIndex(boneMap.name());
|
||||||
for (Entry<String, ?> entry : bonesMap.entries()) {
|
if (boneIndex == -1) throw new SerializationException("Bone not found: " + boneMap.name());
|
||||||
String boneName = entry.key;
|
|
||||||
int boneIndex = skeletonData.findBoneIndex(boneName);
|
|
||||||
if (boneIndex == -1) throw new SerializationException("Bone not found: " + boneName);
|
|
||||||
|
|
||||||
OrderedMap<?, ?> timelineMap = (OrderedMap)entry.value;
|
for (JsonValue timelineMap = boneMap.child(); timelineMap != null; timelineMap = timelineMap.next()) {
|
||||||
for (Entry timelineEntry : timelineMap.entries()) {
|
String timelineName = timelineMap.name();
|
||||||
Array<OrderedMap> values = (Array)timelineEntry.value;
|
|
||||||
String timelineName = (String)timelineEntry.key;
|
|
||||||
if (timelineName.equals(TIMELINE_ROTATE)) {
|
if (timelineName.equals(TIMELINE_ROTATE)) {
|
||||||
RotateTimeline timeline = new RotateTimeline(values.size);
|
RotateTimeline timeline = new RotateTimeline(timelineMap.size());
|
||||||
timeline.setBoneIndex(boneIndex);
|
timeline.setBoneIndex(boneIndex);
|
||||||
|
|
||||||
int frameIndex = 0;
|
int frameIndex = 0;
|
||||||
for (OrderedMap valueMap : values) {
|
for (JsonValue valueMap = timelineMap.child(); valueMap != null; valueMap = valueMap.next()) {
|
||||||
float time = getFloat(valueMap, "time");
|
float time = valueMap.getFloat("time");
|
||||||
timeline.setFrame(frameIndex, time, getFloat(valueMap, "angle"));
|
timeline.setFrame(frameIndex, time, valueMap.getFloat("angle"));
|
||||||
readCurve(timeline, frameIndex, valueMap);
|
readCurve(timeline, frameIndex, valueMap);
|
||||||
frameIndex++;
|
frameIndex++;
|
||||||
}
|
}
|
||||||
@ -237,19 +203,18 @@ public class SkeletonJson {
|
|||||||
TranslateTimeline timeline;
|
TranslateTimeline timeline;
|
||||||
float timelineScale = 1;
|
float timelineScale = 1;
|
||||||
if (timelineName.equals(TIMELINE_SCALE))
|
if (timelineName.equals(TIMELINE_SCALE))
|
||||||
timeline = new ScaleTimeline(values.size);
|
timeline = new ScaleTimeline(timelineMap.size());
|
||||||
else {
|
else {
|
||||||
timeline = new TranslateTimeline(values.size);
|
timeline = new TranslateTimeline(timelineMap.size());
|
||||||
timelineScale = scale;
|
timelineScale = scale;
|
||||||
}
|
}
|
||||||
timeline.setBoneIndex(boneIndex);
|
timeline.setBoneIndex(boneIndex);
|
||||||
|
|
||||||
int frameIndex = 0;
|
int frameIndex = 0;
|
||||||
for (OrderedMap valueMap : values) {
|
for (JsonValue valueMap = timelineMap.child(); valueMap != null; valueMap = valueMap.next()) {
|
||||||
float time = getFloat(valueMap, "time");
|
float time = valueMap.getFloat("time");
|
||||||
Float x = getFloat(valueMap, "x"), y = getFloat(valueMap, "y");
|
Float x = valueMap.getFloat("x"), y = valueMap.getFloat("y");
|
||||||
timeline
|
timeline.setFrame(frameIndex, time, x == null ? 0 : (x * timelineScale), y == null ? 0 : (y * timelineScale));
|
||||||
.setFrame(frameIndex, time, x == null ? 0 : (x * timelineScale), y == null ? 0 : (y * timelineScale));
|
|
||||||
readCurve(timeline, frameIndex, valueMap);
|
readCurve(timeline, frameIndex, valueMap);
|
||||||
frameIndex++;
|
frameIndex++;
|
||||||
}
|
}
|
||||||
@ -257,29 +222,23 @@ public class SkeletonJson {
|
|||||||
duration = Math.max(duration, timeline.getFrames()[timeline.getFrameCount() * 3 - 3]);
|
duration = Math.max(duration, timeline.getFrames()[timeline.getFrameCount() * 3 - 3]);
|
||||||
|
|
||||||
} else
|
} else
|
||||||
throw new RuntimeException("Invalid timeline type for a bone: " + timelineName + " (" + boneName + ")");
|
throw new RuntimeException("Invalid timeline type for a bone: " + timelineName + " (" + timelineMap.name() + ")");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OrderedMap<String, ?> slotsMap = (OrderedMap)map.get("slots");
|
for (JsonValue slotMap = map.getChild("slots"); slotMap != null; slotMap = slotMap.next()) {
|
||||||
if (slotsMap != null) {
|
int slotIndex = skeletonData.findSlotIndex(slotMap.name());
|
||||||
for (Entry<String, ?> entry : slotsMap.entries()) {
|
|
||||||
String slotName = entry.key;
|
|
||||||
int slotIndex = skeletonData.findSlotIndex(slotName);
|
|
||||||
OrderedMap<?, ?> timelineMap = (OrderedMap)entry.value;
|
|
||||||
|
|
||||||
for (Entry timelineEntry : timelineMap.entries()) {
|
for (JsonValue timelineMap = slotMap.child(); timelineMap != null; timelineMap = timelineMap.next()) {
|
||||||
Array<OrderedMap> values = (Array)timelineEntry.value;
|
String timelineName = (String)timelineMap.name();
|
||||||
String timelineName = (String)timelineEntry.key;
|
|
||||||
if (timelineName.equals(TIMELINE_COLOR)) {
|
if (timelineName.equals(TIMELINE_COLOR)) {
|
||||||
ColorTimeline timeline = new ColorTimeline(values.size);
|
ColorTimeline timeline = new ColorTimeline(timelineMap.size());
|
||||||
timeline.setSlotIndex(slotIndex);
|
timeline.setSlotIndex(slotIndex);
|
||||||
|
|
||||||
int frameIndex = 0;
|
int frameIndex = 0;
|
||||||
for (OrderedMap valueMap : values) {
|
for (JsonValue valueMap = timelineMap.child(); valueMap != null; valueMap = valueMap.next()) {
|
||||||
float time = getFloat(valueMap, "time");
|
float time = valueMap.getFloat("time");
|
||||||
Color color = Color.valueOf((String)valueMap.get("color"));
|
Color color = Color.valueOf(valueMap.getString("color"));
|
||||||
timeline.setFrame(frameIndex, time, color.r, color.g, color.b, color.a);
|
timeline.setFrame(frameIndex, time, color.r, color.g, color.b, color.a);
|
||||||
readCurve(timeline, frameIndex, valueMap);
|
readCurve(timeline, frameIndex, valueMap);
|
||||||
frameIndex++;
|
frameIndex++;
|
||||||
@ -288,20 +247,19 @@ public class SkeletonJson {
|
|||||||
duration = Math.max(duration, timeline.getFrames()[timeline.getFrameCount() * 5 - 5]);
|
duration = Math.max(duration, timeline.getFrames()[timeline.getFrameCount() * 5 - 5]);
|
||||||
|
|
||||||
} else if (timelineName.equals(TIMELINE_ATTACHMENT)) {
|
} else if (timelineName.equals(TIMELINE_ATTACHMENT)) {
|
||||||
AttachmentTimeline timeline = new AttachmentTimeline(values.size);
|
AttachmentTimeline timeline = new AttachmentTimeline(timelineMap.size());
|
||||||
timeline.setSlotIndex(slotIndex);
|
timeline.setSlotIndex(slotIndex);
|
||||||
|
|
||||||
int frameIndex = 0;
|
int frameIndex = 0;
|
||||||
for (OrderedMap valueMap : values) {
|
for (JsonValue valueMap = timelineMap.child(); valueMap != null; valueMap = valueMap.next()) {
|
||||||
float time = getFloat(valueMap, "time");
|
float time = valueMap.getFloat("time");
|
||||||
timeline.setFrame(frameIndex++, time, (String)valueMap.get("name"));
|
timeline.setFrame(frameIndex++, time, valueMap.getString("name"));
|
||||||
}
|
}
|
||||||
timelines.add(timeline);
|
timelines.add(timeline);
|
||||||
duration = Math.max(duration, timeline.getFrames()[timeline.getFrameCount() - 1]);
|
duration = Math.max(duration, timeline.getFrames()[timeline.getFrameCount() - 1]);
|
||||||
|
|
||||||
} else
|
} else
|
||||||
throw new RuntimeException("Invalid timeline type for a slot: " + timelineName + " (" + slotName + ")");
|
throw new RuntimeException("Invalid timeline type for a slot: " + timelineName + " (" + timelineMap.name() + ")");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,14 +267,13 @@ public class SkeletonJson {
|
|||||||
skeletonData.addAnimation(new Animation(name, timelines, duration));
|
skeletonData.addAnimation(new Animation(name, timelines, duration));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readCurve (CurveTimeline timeline, int frameIndex, OrderedMap valueMap) {
|
private void readCurve (CurveTimeline timeline, int frameIndex, JsonValue valueMap) {
|
||||||
Object curveObject = valueMap.get("curve");
|
JsonValue curve = valueMap.get("curve");
|
||||||
if (curveObject == null) return;
|
if (curve == null) return;
|
||||||
if (curveObject.equals("stepped"))
|
if (curve.isString() && curve.asString().equals("stepped"))
|
||||||
timeline.setStepped(frameIndex);
|
timeline.setStepped(frameIndex);
|
||||||
else if (curveObject instanceof Array) {
|
else if (curve.isArray()) {
|
||||||
Array curve = (Array)curveObject;
|
timeline.setCurve(frameIndex, curve.getFloat(0), curve.getFloat(1), curve.getFloat(2), curve.getFloat(3));
|
||||||
timeline.setCurve(frameIndex, getFloat(curve, 0), getFloat(curve, 1), getFloat(curve, 2), getFloat(curve, 3));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,9 @@ package com.esotericsoftware.spine;
|
|||||||
import com.esotericsoftware.spine.attachments.Attachment;
|
import com.esotericsoftware.spine.attachments.Attachment;
|
||||||
import com.esotericsoftware.spine.attachments.RegionAttachment;
|
import com.esotericsoftware.spine.attachments.RegionAttachment;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
import com.badlogic.gdx.graphics.GL10;
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
import static com.badlogic.gdx.graphics.g2d.SpriteBatch.*;
|
import static com.badlogic.gdx.graphics.g2d.SpriteBatch.*;
|
||||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||||
@ -12,6 +14,8 @@ import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
|
|||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
|
||||||
public class SkeletonRendererDebug {
|
public class SkeletonRendererDebug {
|
||||||
|
static private final Color slotLineColor = new Color(0, 0, 1, 0.5f);
|
||||||
|
|
||||||
private ShapeRenderer renderer;
|
private ShapeRenderer renderer;
|
||||||
|
|
||||||
public SkeletonRendererDebug () {
|
public SkeletonRendererDebug () {
|
||||||
@ -19,6 +23,7 @@ public class SkeletonRendererDebug {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void draw (SpriteBatch batch, Skeleton skeleton) {
|
public void draw (SpriteBatch batch, Skeleton skeleton) {
|
||||||
|
Gdx.gl.glEnable(GL10.GL_BLEND);
|
||||||
renderer.begin(ShapeType.Line);
|
renderer.begin(ShapeType.Line);
|
||||||
|
|
||||||
renderer.setColor(Color.RED);
|
renderer.setColor(Color.RED);
|
||||||
@ -31,7 +36,7 @@ public class SkeletonRendererDebug {
|
|||||||
renderer.line(bone.worldX, bone.worldY, x, y);
|
renderer.line(bone.worldX, bone.worldY, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer.setColor(Color.BLUE);
|
renderer.setColor(slotLineColor);
|
||||||
Array<Slot> slots = skeleton.getSlots();
|
Array<Slot> slots = skeleton.getSlots();
|
||||||
for (int i = 0, n = slots.size; i < n; i++) {
|
for (int i = 0, n = slots.size; i < n; i++) {
|
||||||
Slot slot = slots.get(i);
|
Slot slot = slots.get(i);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user