mircha Posted May 27, 2020 Share Posted May 27, 2020 Hi. First of all, I want to thank the members of the Pixi.js team for developing this great library. My problem is in using sprite height. For example, see the code below. let onKey = PIXI.Sprite.from("ont.png"); onKey.x = 50; onKey.y = window.innerHeight - (onKey.height + 50); console.log(onKey.height); onKey.scale.set(0.3); app.stage.addChild(onKey); here I want to use sprite height to set a sprite y, but sprite height is always a number between 0 to 1! in this code onKey.height is 1 and if I change the location of onKey.scale.set(0.3) to above the onKey.y, the onKey.height will change to 0.3. I want to use the actual size of the sprite height not its scale. The strange thing is that when I refresh the page several times, the height sometimes changes to the actual size. What's wrong with my code? and my second question is about responsive in pixi.js. here is my code: var app = new PIXI.Application({ width: window.innerWidth, height: window.innerHeight, backgroundColor: 0x000000, antialias: true, //transparent: true, resizeTo: window.addEventListener("resize", function() { app.renderer.resize(window.innerWidth, window.innerHeight); }) }); as you can see I use resizeTo, but only the background of my pixi.js app is responsive. after changing the page size for rearranging the sprites I have to refresh the page. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted May 27, 2020 Share Posted May 27, 2020 Its always 1 in that place because its async loading. I believe this question is asked every week Use a loader to prevent that. If you dont know what loader is , look at https://github.com/kittykatattack/learningPixi Quote Link to comment Share on other sites More sharing options...
mircha Posted May 27, 2020 Author Share Posted May 27, 2020 thank you. with using loader my problem solved. ivan.popelyshev 1 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.