mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 22:34:53 +08:00
parent
873e638b6e
commit
6cccbf61f3
@ -531,18 +531,16 @@ public class Animation {
|
||||
|
||||
public void apply (Skeleton skeleton, float lastTime, float time, Array<Event> events, float alpha) {
|
||||
float[] frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
if (lastTime > time) apply(skeleton, lastTime, Integer.MAX_VALUE, null, 0);
|
||||
return;
|
||||
} else if (lastTime > time) //
|
||||
lastTime = -1;
|
||||
if (time < frames[0]) return; // Time is before first frame.
|
||||
|
||||
int frame = (time >= frames[frames.length - 1] ? frames.length : binarySearch(frames, time)) - 1;
|
||||
if (frames[frame] < lastTime) return;
|
||||
int frameIndex;
|
||||
if (time >= frames[frames.length - 1]) // Time is after last frame.
|
||||
frameIndex = frames.length - 1;
|
||||
else
|
||||
frameIndex = binarySearch(frames, time, 1) - 1;
|
||||
|
||||
String attachmentName = attachmentNames[frame];
|
||||
skeleton.slots.get(slotIndex)
|
||||
.setAttachment(attachmentName == null ? null : skeleton.getAttachment(slotIndex, attachmentName));
|
||||
String attachmentName = attachmentNames[frameIndex];
|
||||
skeleton.slots.get(slotIndex).attachmentName = attachmentName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -530,7 +530,7 @@ public class Skeleton {
|
||||
for (int i = 0, n = drawOrder.size; i < n; i++) {
|
||||
Slot slot = drawOrder.get(i);
|
||||
float[] vertices = null;
|
||||
Attachment attachment = slot.attachment;
|
||||
Attachment attachment = slot.getAttachment();
|
||||
if (attachment instanceof RegionAttachment)
|
||||
vertices = ((RegionAttachment)attachment).updateWorldVertices(slot, false);
|
||||
else if (attachment instanceof MeshAttachment) //
|
||||
|
||||
@ -61,7 +61,7 @@ public class SkeletonBounds {
|
||||
|
||||
for (int i = 0; i < slotCount; i++) {
|
||||
Slot slot = slots.get(i);
|
||||
Attachment attachment = slot.attachment;
|
||||
Attachment attachment = slot.getAttachment();
|
||||
if (attachment instanceof BoundingBoxAttachment) {
|
||||
BoundingBoxAttachment boundingBox = (BoundingBoxAttachment)attachment;
|
||||
boundingBoxes.add(boundingBox);
|
||||
|
||||
@ -52,7 +52,7 @@ public class SkeletonMeshRenderer extends SkeletonRenderer<PolygonSpriteBatch> {
|
||||
Array<Slot> drawOrder = skeleton.drawOrder;
|
||||
for (int i = 0, n = drawOrder.size; i < n; i++) {
|
||||
Slot slot = drawOrder.get(i);
|
||||
Attachment attachment = slot.attachment;
|
||||
Attachment attachment = slot.getAttachment();
|
||||
Texture texture = null;
|
||||
if (attachment instanceof RegionAttachment) {
|
||||
RegionAttachment region = (RegionAttachment)attachment;
|
||||
|
||||
@ -48,7 +48,7 @@ public class SkeletonRenderer<T extends Batch> {
|
||||
Array<Slot> drawOrder = skeleton.drawOrder;
|
||||
for (int i = 0, n = drawOrder.size; i < n; i++) {
|
||||
Slot slot = drawOrder.get(i);
|
||||
Attachment attachment = slot.attachment;
|
||||
Attachment attachment = slot.getAttachment();
|
||||
if (attachment instanceof RegionAttachment) {
|
||||
RegionAttachment regionAttachment = (RegionAttachment)attachment;
|
||||
float[] vertices = regionAttachment.updateWorldVertices(slot, premultipliedAlpha);
|
||||
|
||||
@ -102,7 +102,7 @@ public class SkeletonRendererDebug {
|
||||
Array<Slot> slots = skeleton.getSlots();
|
||||
for (int i = 0, n = slots.size; i < n; i++) {
|
||||
Slot slot = slots.get(i);
|
||||
Attachment attachment = slot.attachment;
|
||||
Attachment attachment = slot.getAttachment();
|
||||
if (attachment instanceof RegionAttachment) {
|
||||
RegionAttachment regionAttachment = (RegionAttachment)attachment;
|
||||
float[] vertices = regionAttachment.updateWorldVertices(slot, false);
|
||||
@ -118,7 +118,7 @@ public class SkeletonRendererDebug {
|
||||
Array<Slot> slots = skeleton.getSlots();
|
||||
for (int i = 0, n = slots.size; i < n; i++) {
|
||||
Slot slot = slots.get(i);
|
||||
Attachment attachment = slot.attachment;
|
||||
Attachment attachment = slot.getAttachment();
|
||||
if (!(attachment instanceof MeshAttachment)) continue;
|
||||
MeshAttachment mesh = (MeshAttachment)attachment;
|
||||
mesh.updateWorldVertices(slot, false);
|
||||
@ -167,7 +167,7 @@ public class SkeletonRendererDebug {
|
||||
Array<Slot> slots = skeleton.getSlots();
|
||||
for (int i = 0, n = slots.size; i < n; i++) {
|
||||
Slot slot = slots.get(i);
|
||||
Attachment attachment = slot.attachment;
|
||||
Attachment attachment = slot.getAttachment();
|
||||
if (!(attachment instanceof PathAttachment)) continue;
|
||||
PathAttachment path = (PathAttachment)attachment;
|
||||
int nn = path.getWorldVerticesLength();
|
||||
|
||||
@ -102,7 +102,7 @@ public class Skin {
|
||||
for (Entry<Key, Attachment> entry : oldSkin.attachments.entries()) {
|
||||
int slotIndex = entry.key.slotIndex;
|
||||
Slot slot = skeleton.slots.get(slotIndex);
|
||||
if (slot.attachment == entry.value) {
|
||||
if (slot.getAttachment() == entry.value) {
|
||||
Attachment attachment = getAttachment(slotIndex, entry.key.name);
|
||||
if (attachment != null) slot.setAttachment(attachment);
|
||||
}
|
||||
|
||||
@ -31,18 +31,18 @@
|
||||
|
||||
package com.esotericsoftware.spine;
|
||||
|
||||
import com.esotericsoftware.spine.attachments.Attachment;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.utils.FloatArray;
|
||||
import com.esotericsoftware.spine.attachments.Attachment;
|
||||
|
||||
public class Slot {
|
||||
final SlotData data;
|
||||
final Bone bone;
|
||||
final Color color;
|
||||
Attachment attachment;
|
||||
private Attachment attachment;
|
||||
private float attachmentTime;
|
||||
private FloatArray attachmentVertices = new FloatArray();
|
||||
String attachmentName;
|
||||
|
||||
public Slot (SlotData data, Bone bone) {
|
||||
if (data == null) throw new IllegalArgumentException("data cannot be null.");
|
||||
@ -82,6 +82,10 @@ public class Slot {
|
||||
|
||||
/** @return May be null. */
|
||||
public Attachment getAttachment () {
|
||||
if (attachmentName != null) {
|
||||
attachment = bone.skeleton.getAttachment(data.index, attachmentName);
|
||||
attachmentName = null;
|
||||
}
|
||||
return attachment;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user