Jump to content

PIXI 2.0 - DisplayObjectContainer width/height increasing on every call to width/height


dst
 Share

Recommended Posts

Hi, noticed a potential issue with Pixi 2.0. If I add two or more Graphics objects to a DisplayObjectContainer, placing them at different x or y values, every time I call width/height on the DisplayObjectContainer it is an increasing value.

 

Example:

function init() {    var canvas = document.getElementById('canvas');    canvas.style.width = String(window.innerWidth) + "px";    canvas.style.height = String(window.innerHeight) + "px";    var options = {        view:canvas,        resolution:window.devicePixelRatio    };    renderer = PIXI.autoDetectRecommendedRenderer(window.innerWidth, window.innerHeight, options);    stage = new PIXI.Stage(0xFFFFFF);    container = new PIXI.DisplayObjectContainer();    stage.addChild(container);    for(var i = 0; i < 2; i++) {        var rect = new PIXI.Graphics();        rect.beginFill(0xCCCCCC, 0.4);        rect.drawRect(0, 0, 50, 50);        rect.endFill();        rect.x += i * 100;        container.addChild(rect);    }    console.log("container.width: ", container.width);    console.log("container.width: ", container.width);    console.log("container.width: ", container.width);    console.log("container.width: ", container.width);    console.log("container.width: ", container.width);    console.log("container.width: ", container.width);    console.log("container.width: ", container.width);    renderer.render(stage);    requestAnimFrame(update);}function update() {    renderer.render(stage);    requestAnimFrame(update);}

 

 

This logs the following:

container.width:  150 container.width:  250 container.width:  350 container.width:  450 container.width:  550 container.width:  650 container.width:  750 
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...