【发布时间】:2015-07-01 10:56:12
【问题描述】:
在调用自动渲染器之前,我需要获取刚刚添加到舞台的图像大小并将其设置为 defaultX 和 defaultY,但我似乎无法获取大小。 我如何抓住尺寸? 另外,从我目前得到的信息来看,我认为设置大小的最佳方法是使用自动渲染器。但是,如果我稍后 resize() 会有什么影响? 任何帮助将不胜感激。谢谢。
我的代码:
this.stage = new PIXI.Container();
var texture = PIXI.Texture.fromImage('background.png'); //1610x640
var spr = new PIXI.Sprite(texture);
this.stage.addChild(spr);
defaultX = texture.width;
defaultY = texture.height;
this.renderer = PIXI.autoDetectRenderer(defaultX, defaultY); //640x690
this.renderer.resize(x,y); // I know this works with other values
// eg if I hardcode with 1610,640
// but texture.width doesn't work and
// I don't want to hardcode it
【问题讨论】:
标签: pixi.js