Quantcast
Channel: Pixi.js Latest Topics
Viewing all articles
Browse latest Browse all 3978

problem in sprite height

$
0
0

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. 


Viewing all articles
Browse latest Browse all 3978

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>