Jump to content

Replace the whole sprite sheet in pixi+spine


Recommended Posts

I'd like to be able in runtime to replace the sprite sheet with the HD version in runtime.

i've tried using `hackTextureBySlotIndex` and iterating over all slots, but it requires already cropped textures, and i just want to swap the whole thing.

is it possible to do so without swapping the whole spine object? or is it impossible because of resolution changes?

Link to comment
Share on other sites

Its possible, but I wont help with it because im sick right now. I'll add your case in examples if you actually make it. All necessary parts of code already exist.

Examples contain several cases on how to manually load atlas and skeleton data. By combining them you can achieve what you want.


Also it might be interesting how actually loader works:



Link to comment
Share on other sites

If you want to evade re-creation of texture regions, you need to hack it on loading stage.

If you want to change it in runtime, with existing Spine object - that's a big problem, you have to change all texture regions across attachments and already created sprite and mesh instances. Original spine runtime doesn't allow change of textures in runtime except through skins. pixi-spine allows some extra things. This is the first time I hear that someone needs to change whole atlas to different resolution, and if you explain why do you need it, and why other people also might need it, I might to code it myself. 

Link to comment
Share on other sites

thank you, that's exactly how i managed to hack it, is with re-creation of texture regions:

var partTexture = new PIXI.Texture(hdTexture,new PIXI.Rectangle(xPos,yPos,cropWidth,cropHeight));
spine.hackTextureBySlotIndex(i, partTexture, { width: slot.attachment.width, height: slot.attachment.height });

and it worked fine with higher res texture (as long as I do the region math).

what i want to provide the user is "NETFLIX like" experience, that if the CPU is struggling to run, i'll be able to swap seamlessly the whole texture for lower res and vise versa.

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.

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.


  • Recently Browsing   0 members

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