Dina Posted May 15, 2020 Share Posted May 15, 2020 Hello PIXI community! let image = PIXI.Sprite.from("imagePath"); I don't use loader for creating images and I pass this to a module where I need to get the real width of the image, but I get the width equal to 1 as I don't use loader (Hope I get this part right). So I used loader to get the real width but I got problems with passing the image to module as the image is used in setup function that is passed to loader. English is not my native language. Hope this makes sense)) So how do I create an image outside of the module and pass it to use it's width? Quote Link to comment Share on other sites More sharing options...
themoonrat Posted May 17, 2020 Share Posted May 17, 2020 When you're not using a preloader... the width is 1 until the image had been loaded. We can't know the true width of something if it's not been loaded yet. When it has, an event on the texture is fired and the true value can be known. If using a loader, then it'll give you the references to things it loads which you can pass in elsewhere. The built in loader will add textures loaded into PIXI.utils.TextureCache that you can reference from anywhere. Dina 1 Quote Link to comment Share on other sites More sharing options...
Dina Posted May 18, 2020 Author Share Posted May 18, 2020 (edited) @themoonrat thanks a lot Edited May 19, 2020 by Dina 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.