【问题标题】:Pixi.Texture, get height and widthPixi.Texture,获取高度和宽度
【发布时间】:2017-12-26 13:36:34
【问题描述】:

我试图从精灵的纹理中获取宽度和高度。根据文档,属性应该可用,并且在执行 console.log(texture) 时它们是正确的,但是在执行 console.log(texture.height) 时它总是返回 1。这是代码:

let texture = PIXI.Texture.fromImage(path);
    console.log(texture);
    console.log(texture.height);

console.log(texture) 显示:

...

_updateID:2
_uvs:t
frame:(...)
height:240
rotate:0
width:240

...

这是正确的宽度和高度,但为什么我不能得到值?

【问题讨论】:

    标签: textures sprite pixi.js


    【解决方案1】:

    我发现了问题所在。在我尝试获取值之前,纹理可能没有正确加载。我使用 PIXI 加载器对象来预加载所有纹理,现在它可以完美运行了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-10
      • 2021-06-30
      • 2010-11-18
      • 1970-01-01
      • 2023-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多