Jump to content

Spine hierarchy


Upsinn
 Share

Recommended Posts

Hi,

how can I get access to specific slot in my spine skeleton? I have simple spine skeleton animation and sprite which is a few display layers under the spine skeleton, and I need that sprite will be reproduce moves of specific slot. Is there any way how can I get global coords of the slots? Thx 

Link to comment
Share on other sites

Its not a problem. You can either track its slot position, either just add sprite there. If you want to have it different z-index you can use pixi-display library.

I recommend you to study the sources anyway, that will help you a lot.

var index = spine.skeleton.findSlotIndex('slotName');
var slot = spine.skeleton.slots[index];
var slotContainer = spine.slotContainers[index];

//option 1 just add sprite to container
slotContainer.addChild(mySprite);
//assign different displaygroup if you use pixi-display. That way sprite will appear after actual spine object, where you need it
mySprite.displayGroup = foregroundGroup;

//option 2 track the matrix
spine.updateTransform();
// slotContainer.worldTransform is the matrix. I dont know what do you want to do with it exactly 
var point = new PIXI.Point(slotContainer.worldTransform.tx, slotContainer.worldTransform.ty);

 

Link to comment
Share on other sites

8 minutes ago, Upsinn said:

Thanks a lot - pixi-display sounds great and its exactly what I need. Btw.: Is there any way how can I dispatch event for every update of my skeleton in pixi-spine?

wll you can just hack it, put your own function in prototype that hides original "update". But you have to understand that there are two parts of it: bones update and transform update. Bones are updated by spine runtime , while transform (sprite.worldTransform) are PIXI thing. If you turn of autoUpdate of this particular spine or even all spine instances, you can hook "spine.update(dt)" into your own cycle , and that way spine updates will be all yours :) Anyway, better to read the code, especially "Spine/index.js" part

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...