trishul1979 Posted November 3, 2015 Share Posted November 3, 2015 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.jsvar 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. Quote Link to comment Share on other sites More sharing options...
trishul1979 Posted November 3, 2015 Author Share Posted November 3, 2015 Issue solved. If we set width height of container the scale.x/scale.y property changes which was causing the issue.I separated code for this. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.