mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-19 08:16:41 +08:00
Made consistent when slot vertices and attachment time are reset.
setAttachment resets vertices and attachment time only if the attachment actually changed. setToSetupPose always resets vertices and attachment time. http://esotericsoftware.com/forum/Spine-API-SetToSetupPose-FFD-Questions-2102?p=26119#p26119
This commit is contained in:
parent
c7bb3f3af8
commit
318b9939e6
@ -71,6 +71,7 @@ public class Slot {
|
||||
/** Sets the attachment and resets {@link #getAttachmentTime()}.
|
||||
* @param attachment May be null. */
|
||||
public function set attachment (attachment:Attachment) : void {
|
||||
if (_attachment == attachment) return;
|
||||
_attachment = attachment;
|
||||
_attachmentTime = _bone._skeleton.time;
|
||||
attachmentVertices.length = 0;
|
||||
@ -91,7 +92,12 @@ public class Slot {
|
||||
g = _data.g;
|
||||
b = _data.b;
|
||||
a = _data.a;
|
||||
attachment = _data.attachmentName == null ? null : _bone._skeleton.getAttachmentForSlotIndex(slotIndex, data.attachmentName);
|
||||
if (_data.attachmentName == null)
|
||||
attachment = null;
|
||||
else {
|
||||
_attachment = null;
|
||||
attachment = _bone._skeleton.getAttachmentForSlotIndex(slotIndex, data.attachmentName);
|
||||
}
|
||||
}
|
||||
|
||||
public function toString () : String {
|
||||
|
||||
@ -51,6 +51,7 @@ void spSlot_dispose (spSlot* self) {
|
||||
}
|
||||
|
||||
void spSlot_setAttachment (spSlot* self, spAttachment* attachment) {
|
||||
if (attachment == self->attachment) return;
|
||||
CONST_CAST(spAttachment*, self->attachment) = attachment;
|
||||
SUB_CAST(_spSlot, self)->attachmentTime = self->bone->skeleton->time;
|
||||
self->attachmentVerticesCount = 0;
|
||||
@ -72,7 +73,9 @@ void spSlot_setToSetupPose (spSlot* self) {
|
||||
self->b = self->data->b;
|
||||
self->a = self->data->a;
|
||||
|
||||
if (self->data->attachmentName) {
|
||||
if (!self->data->attachmentName)
|
||||
spSlot_setAttachment(self, 0);
|
||||
else {
|
||||
/* Find slot index. */
|
||||
int i;
|
||||
for (i = 0; i < self->bone->skeleton->data->slotsCount; ++i) {
|
||||
@ -81,6 +84,7 @@ void spSlot_setToSetupPose (spSlot* self) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
CONST_CAST(spAttachment*, self->attachment) = 0;
|
||||
spSlot_setAttachment(self, attachment);
|
||||
}
|
||||
spSlot_setAttachment(self, attachment);
|
||||
}
|
||||
|
||||
@ -55,6 +55,7 @@ namespace Spine {
|
||||
return attachment;
|
||||
}
|
||||
set {
|
||||
if (attachment == value) return;
|
||||
attachment = value;
|
||||
attachmentTime = bone.skeleton.time;
|
||||
attachmentVerticesCount = 0;
|
||||
@ -86,7 +87,12 @@ namespace Spine {
|
||||
g = data.g;
|
||||
b = data.b;
|
||||
a = data.a;
|
||||
Attachment = data.attachmentName == null ? null : bone.skeleton.GetAttachment(slotIndex, data.attachmentName);
|
||||
if (data.attachmentName == null)
|
||||
Attachment = null;
|
||||
else {
|
||||
attachment = null;
|
||||
Attachment = bone.skeleton.GetAttachment(slotIndex, data.attachmentName);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetToSetupPose () {
|
||||
|
||||
@ -178,6 +178,7 @@ spine.Slot.prototype = {
|
||||
attachment: null,
|
||||
attachmentVertices: [],
|
||||
setAttachment: function (attachment) {
|
||||
if (this.attachment == attachment) return;
|
||||
this.attachment = attachment;
|
||||
this._attachmentTime = this.bone.skeleton.time;
|
||||
this.attachmentVertices.length = 0;
|
||||
@ -195,11 +196,16 @@ spine.Slot.prototype = {
|
||||
this.b = data.b;
|
||||
this.a = data.a;
|
||||
|
||||
var slotDatas = this.bone.skeleton.data.slots;
|
||||
for (var i = 0, n = slotDatas.length; i < n; i++) {
|
||||
if (slotDatas[i] == data) {
|
||||
this.setAttachment(!data.attachmentName ? null : this.bone.skeleton.getAttachmentBySlotIndex(i, data.attachmentName));
|
||||
break;
|
||||
if (!data.attachmentName)
|
||||
this.setAttachment(null);
|
||||
else {
|
||||
var slotDatas = this.bone.skeleton.data.slots;
|
||||
for (var i = 0, n = slotDatas.length; i < n; i++) {
|
||||
if (slotDatas[i] == data) {
|
||||
this.attachment = null;
|
||||
this.setAttachment(this.bone.skeleton.getAttachmentBySlotIndex(i, data.attachmentName));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,10 +91,10 @@ public class Slot {
|
||||
return attachment;
|
||||
}
|
||||
|
||||
/** Sets the attachment, resets {@link #getAttachmentTime()}, and clears {@link #getAttachmentVertices()}.
|
||||
/** Sets the attachment and if it changed, resets {@link #getAttachmentTime()} and clears {@link #getAttachmentVertices()}.
|
||||
* @param attachment May be null. */
|
||||
public void setAttachment (Attachment attachment) {
|
||||
if (this.attachment == attachment) return;
|
||||
if (this.attachment != attachment) return;
|
||||
this.attachment = attachment;
|
||||
attachmentTime = bone.skeleton.time;
|
||||
attachmentVertices.clear();
|
||||
@ -119,7 +119,12 @@ public class Slot {
|
||||
|
||||
void setToSetupPose (int slotIndex) {
|
||||
color.set(data.color);
|
||||
setAttachment(data.attachmentName == null ? null : bone.skeleton.getAttachment(slotIndex, data.attachmentName));
|
||||
if (data.attachmentName == null)
|
||||
setAttachment(null);
|
||||
else {
|
||||
attachment = null;
|
||||
setAttachment(bone.skeleton.getAttachment(slotIndex, data.attachmentName));
|
||||
}
|
||||
}
|
||||
|
||||
public void setToSetupPose () {
|
||||
|
||||
@ -52,6 +52,7 @@ function Slot.new (slotData, bone)
|
||||
end
|
||||
|
||||
function self:setAttachment (attachment)
|
||||
if self.attachment == attachment then return end
|
||||
self.attachment = attachment
|
||||
self.attachmentTime = self.bone.skeleton.time
|
||||
self.attachmentVerticesCount = 0
|
||||
@ -70,11 +71,12 @@ function Slot.new (slotData, bone)
|
||||
|
||||
self:setColor(data.r, data.g, data.b, data.a)
|
||||
|
||||
local attachment
|
||||
if data.attachmentName then
|
||||
attachment = self.bone.skeleton:getAttachment(data.name, data.attachmentName)
|
||||
if not data.attachmentName then
|
||||
self:setAttachment(nil)
|
||||
else
|
||||
self.attachment = nil
|
||||
self:setAttachment(self.bone.skeleton:getAttachment(data.name, data.attachmentName))
|
||||
end
|
||||
self:setAttachment(attachment)
|
||||
end
|
||||
|
||||
self:setToSetupPose()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user