mityok Posted October 17, 2017 Share Posted October 17, 2017 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? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted October 17, 2017 Share Posted October 17, 2017 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. https://github.com/pixijs/pixi-spine/tree/master/examples Also it might be interesting how actually loader works: https://github.com/pixijs/pixi-spine/blob/master/src/loaders.ts#L65 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted October 17, 2017 Share Posted October 17, 2017 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. Quote Link to comment Share on other sites More sharing options...
mityok Posted October 18, 2017 Author Share Posted October 18, 2017 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. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted October 18, 2017 Share Posted October 18, 2017 Texture size doesnt matter, renderer resolution does. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.