Jump to content

problem in sprite height


mircha
 Share

Recommended Posts

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. 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...