amshegarh Posted September 13, 2019 Share Posted September 13, 2019 I've seen this question before, has anything changed? I need to get texture(s) from spritesheet, sometimes texture needs to be cut in several ones and placed in different sprites, previous answer only took texture from img src and it was something more complicated than it should be for task this simple Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 13, 2019 Share Posted September 13, 2019 still "new PIXI.Texture(baseTexture, frame, trim, orig, rotate)". Frame is obvious, but sometimes you need extra stuff, and i cant explain other params in this thread, look in the docs. After 2-3 fails you'll get it I dont know how to make it easier. If you want to make it even easier - propose an API for it. Yes, sometimes in private code I use methods that actually cut texture region to more texture regions, for example for NineSlice or to sort objects in isometry and cut sprites with multiple vertical lines. This is one of such attempts for pixi-v4: https://github.com/gameofbombs/pixi-heaven/tree/master/srcOld/base/atlas but it doesnt have nor good API's nor docs. Quote Link to comment Share on other sites More sharing options...
mobileben Posted September 17, 2019 Share Posted September 17, 2019 What are you trying to do? When you say a texture needs to be cut into several ones is how it cut determined at runtime? Quote Link to comment Share on other sites More sharing options...
amshegarh Posted September 17, 2019 Author Share Posted September 17, 2019 Yeah I have a working function already to cut a texture, not sure about its performance, but it does work ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
mobileben Posted September 17, 2019 Share Posted September 17, 2019 By cutting do you mean generating new UVs? Or really generating a new texture? Since you are not fully describing things, it does make it more difficult for people to help you. Quote Link to comment Share on other sites More sharing options...
amshegarh Posted September 20, 2019 Author Share Posted September 20, 2019 Ok there is a problem, when i try to refer to base texture of a texture in spritesheet in such fashion PIXI.Loader.shared.resources["spritesheet"].spritesheet.textures["Image144.png"].baseTexture returned base texture is in fact of the whole spritesheet, but i need base texture of a single texture in spritesheet How do i do that Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 20, 2019 Share Posted September 20, 2019 ok, you have frame of original texture in that baseTexture, right? consider it frame1. you want to trim it, frame2. Resulting frame will be "(frame1.x + frame2.x, frame1.y + frame2.y, frame2.width, frame2.height)" . That's the problem i talked about - that basic addition of frames does not exist in pixi. You have to use your programming skills on it PixiJS doesnt have to do everything for you . If that info is not enough, i can make demo in weekend. In my case it was like that: https://github.com/gameofbombs/pixi-heaven/blob/master/srcOld/base/atlas/TextureRegion.ts#L17 , but you cant just ctrl+c that code, because i used extra fields for my atlas. Quote Link to comment Share on other sites More sharing options...
amshegarh Posted September 20, 2019 Author Share Posted September 20, 2019 Unfortunate, oh well, i guess i'll just have to write another function, i'll just assume that PIXI.Texture.frame is the property i need Thanks Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 20, 2019 Share Posted September 20, 2019 Btw, if you change it directly, like texture.frame.x = something, you have to call updateUvs() afterwards. if you assign texture.frame = something, then you dont need it. 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.