renathy Posted November 23, 2020 Share Posted November 23, 2020 I have about 50 images, I load them into Application. Then I create sprite for each image. Images width and height differs, they are not the same width/height, and images are quite large compared with sprites I need on screen. This is my first App in Pixi.js I am using latest PIXI.jS version. I have defined width (let us say width = 100). I need all sprites to be width = 100, but height should be calculated proportionally based on image (from which texture was created). Is it possible? let mySprite = new PIXI.Sprite(app.loader.resources[imgName].texture); mySprite.anchor.set(0.5, 0.5); mySprite.width = 100; mySprite.height = 100; // instead this should be calculated to fit image proportions I think I do not have problems to do math, but I have problems to get right values against which calculation/proportions should be calculated. Quote Link to comment Share on other sites More sharing options...
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.