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...
ivan.popelyshev Posted November 24, 2020 Share Posted November 24, 2020 (edited) It should work. Whats exactly the problem? oh right.. ok, then you have to assign only width, and do something like "sprite.scale.y=sprite.scale.x" for everything . When you sure its loaded. Edited November 24, 2020 by ivan.popelyshev 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.