Jump to content

Incorrect width/height of container


trishul1979
 Share

Recommended Posts

Hi,

 

I am creating a small game using pixi.js. I am struggling getting width height of container.

The issue is the width/height of container reported through code is different and If I take the screen capture and see the size in photoshop its different and for this reason elements are not properly aligned.

 

cards.js

var GAME = GAME || {};var m_ref = null;GAME.Cards = function() {	PIXI.Container.call(this);	m_ref = this;	this.visible = true;	this._childs = new Array();	this.popup_sprite = new PIXI.Sprite(PIXI.utils.TextureCache["asset/ui/paper-186895_640.jpg"]);	this._childs.push(this.popup_sprite);	this.popup_sprite.anchor.x = this.popup_sprite.anchor.y = 0;	this.popup_sprite.position.x = 0;	this.popup_sprite.position.y = 0;	this.addChild(this.popup_sprite);	this.startDisplay();};GAME.Cards.constructor = GAME.Cards;GAME.Cards.prototype = Object.create(PIXI.Container.prototype);

app.js

_width = window.innerWidth || document.body.clientWidth;_height = window.innerHeight || document.body.clientHeight;cards_scene = new GAME.Cards();var _w = Math.round(_width * 0.7);alert("! : " + _w); // 869var _h = Math.round(_height * 0.8);cards_scene.width = _w;alert(cards_scene.width);// 869cards_scene.height = _h;

If I check in photoshop the width of container is 956 whereas alert(cards_scene.width); reports 869. I am not using any resize code.

 

If the width and height buggy or setting the width and height of Container is buggy.

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