Jump to content

Add width to renderer view without scaling childrens


Mathieu
 Share

Recommended Posts

Hello everyone !

I need to know if there is a way in Pixi to add width to the renderer view without scaling the content.

I already tried using renderer.autoResize = false with no success. 

For example :

// First I set the height of the view
var h = window.innerHeight-100;
renderer.view.style.height = h + "px";

// Then, I set the width with the good factor to keep everything in a good shape
renderer.view.style.width = (h*2.666) + "px";

// I would like to be able to add width after without affecting the shape of the sprites
renderer.view.style.width+=[missingWidthToFillTheScreen];

Do you think it's possible ?
 

 

Link to comment
Share on other sites

//if you wanna auto-update style
renderer = new Renderer(800, 600, { autoResize:true});
renderer.resize(newWidth, newHeight);

//if you want to do it yourself
renderer = new Renderer(800, 600, {});
renderer.resize(newWidth, newHeight);
renderer.view.style.width = newWidth+'px';
renderer.view.style.height = newHeight+'px';

//You dont want to resize canvas, you are totally ok if it will be pixelated
renderer.view.style.width = newWidth+'px';
renderer.view.style.height = newHeight+'px';
stage.scale.x = newWidth/800;
stage.scale.y = newHeight/600;

Renderer and view have its own width/height that are actually CANVAS width/height, it differs from CSS ones.

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...