MyNameIsNate

Hey I'm trying to find where the visibility information is stored on a slot in the skeleton object. And attachments on the slot object don't seem to change whether they get toggled on or off? Its likely something I'm missing so any advice would be much appreciated, thanks.
MyNameIsNate
Сообщения: 7

Nate

Look at Slot attachment.
Аватара пользователя
Nate

Nate
Сообщения: 7281

MyNameIsNate

I did look at slots. Attachments ether seem to be attached 100% of the time or not attached at all throughout the update process even when they are toggled on the timeline. I'm I'm sure I must be missing something but I thought I would post here in case anyone else may have experienced the same issue?
MyNameIsNate
Сообщения: 7

Nate

MyNameIsNate писал(а):Attachments ether seem to be attached 100% of the time or not attached at all throughout the update process
Seem how? What are you checking/looking at? What update process? Do you mean rendering? Rendering is done by getting the attachment for each slot and rendering it. There's not much magic going on. Attachments are stateless and don't know about what slots they are in.
Аватара пользователя
Nate

Nate
Сообщения: 7281

MyNameIsNate

I'm looking at the attachments on the slot objects in the skeleton object when state.update() and skeeton.updateWorldTransform() has been called. Slot object has attachment property. I was assuming this would be set to an attachment when its toggled on on timeline and set to null if toggled off.

If this is not the case can you please tell me how to check for attachments being toggled/visible on a slot please at any point during its state being updated?
MyNameIsNate
Сообщения: 7

Nate

As I said, Slot attachment has the attachment drawn for that slot. It will be null if there is no attachment for the slot. If you don't see it being null after applying an animation which has a key to hide the attachment for that slot, then something else is going on (you are looking at the wrong skeleton, you are applying the wrong animation, the animation doesn't have a key or the key is at a later time, etc). There's many ways to debug it. You can look at AttachmentTimeline and see if it is applying a keyed value.
Аватара пользователя
Nate

Nate
Сообщения: 7281

MyNameIsNate

Honestly I think there may be a bug in the javascript runtime. The attachments are keyed on the slots but the slots are not showing any changes to attachments during time where key should trigger. I'm no expert by any means so I could be missing something.
MyNameIsNate
Сообщения: 7

badlogic

Could you post a reproduction sample that shows the issue?
Аватара пользователя
badlogic

Mario
Сообщения: 830

MyNameIsNate

Hey I think the issue may be with toggling just skin placeholders? Slot objects don't seem to update attachment property when toggled on timeline. Actually I don't think attackement property is ever anything but null on slot object if the attachment is a placeholder? Is this something you may be able to confirm? Thanks
MyNameIsNate
Сообщения: 7

Nate

Skin placeholders only exist in the editor. At runtime a skin maps the skin placeholder name to the attachment to use for that skin.

Why not show us what problem you are having so we can help?
Аватара пользователя
Nate

Nate
Сообщения: 7281

MyNameIsNate

Hey thanks for your help. Here is a snippet of code I'm using to determine if a slot should be visible. The code is running inside an update function which also updated the state and skeleton.
for (var i = 0; i < this.skeleton.drawOrder.length; i++) {
var drawOrder = this.skeleton.drawOrder[i];
if (!drawOrder.attachment) {
drawOrder.createjsSlot.visible = false;
}
else {
drawOrder.createjsSlot.visible = true;
}
};
This issue it would seem is that if the attachment was attached my mapping it to a slot by skin placeholder then drawOrder.attachment is always null throughout the animation, even though there is a timeline in the state object relating to it, it never seems to be applied.

Could you please advise. Thanks
MyNameIsNate
Сообщения: 7

Nate

The code looks OK. Without a full example that shows what is wrong, there's not much more we can do.
Аватара пользователя
Nate

Nate
Сообщения: 7281

badlogic

One more thing I gathered from one of your previous posts is that you only call state.update and skeleton.updateWorldTransforms, but not state.apply. The latter will set the attachments on the slots of the skeleton.
Аватара пользователя
badlogic

Mario
Сообщения: 830

MyNameIsNate

Hey good spot but I'm also calling state.apply() within my update function too. The following is code running the update function.
private update(delta) {
if(!this.animate) return;
delta *= 0.001 * this._params.speed;
this.state.update(delta);
this.state.apply(this.skeleton);
this.skeleton.updateWorldTransform();

this.boneContainers.forEach(function(boneContainer)
{
var bone = boneContainer.spineBone;
boneContainer.x = bone.x;
boneContainer.y = bone.y * -1;
boneContainer.scaleX = bone.scaleX;
boneContainer.scaleY = bone.scaleY;
boneContainer.rotation = -bone.rotation;
});

for (var i = 0; i < this.skeleton.drawOrder.length; i++) {
var drawOrder = this.skeleton.drawOrder[i];
if(drawOrder.createjsSlot) {
if (!drawOrder.attachment) {
drawOrder.createjsSlot.visible = false;
}
else {
drawOrder.createjsSlot.visible = true;
}
}

};
}
Sorry I can't send you the code in its entirety as its not very modular atm integrated into a bigger project.

Would you possibly happen to have sample javascript code showing attachments being toggled at runtime that you could send me?

Thanks
MyNameIsNate
Сообщения: 7

Nate

The skins demo does it to equip the sword (and somewhat more complex, to create a randomized skin):
spine-runtimes/skins.js at master
Live page here:
http://rawgit.com/EsotericSoftware/spine-runtimes/master/spine-ts/webgl/demos/skins.html
All demos on one page:
Spine: Demos
More demo info here:
spine-runtimes/spine-ts at master
Аватара пользователя
Nate

Nate
Сообщения: 7281


Вернуться в Runtimes