【问题标题】:why does adding Sprites to Sprites in Pixi.js result in strange scaling为什么在 Pixi.js 中将 Sprites 添加到 Sprites 会导致奇怪的缩放
【发布时间】:2014-04-14 01:40:55
【问题描述】:

嗨,我想知道为什么 Pixi.js 中的精灵变得比我预期的要大得多。 如果我将我的精灵“bat”添加到我的舞台上,它看起来是正确的,但是当我使用一个名为“background”的精灵并将我的精灵“bat”添加到它时,尺寸就会混乱。

我的背景是这样的

function Background(screenWidth , screenHeight, imgPath)
{
    var bgImage = PIXI.Texture.fromImage(imgPath);
    PIXI.Sprite.call(this, bgImage);
    this.position.x = 0;
    this.position.y = 0;
    this.width = screenWidth;
    this.height = screenHeight;
}
Background.constructor = Background;
Background.prototype = Object.create(PIXI.Sprite.prototype);

Background.prototype.update = function()
{
//DO NOTHING
};

我的舞台与背景的大小完全相同,所以我想知道为什么我的精灵“蝙蝠”的大小会翻倍。 有人知道我在做什么错吗? 提前致谢。

【问题讨论】:

    标签: javascript 2d sprite pixi.js


    【解决方案1】:

    没有看到你的实现,我无法确定为什么它会变得更大。

    但是…… 您是否尝试过将 PIXI.DisplayObjectContainer 放入您的舞台,然后添加您的“背景”和“蝙蝠”?

    如果您不搞乱精灵的缩放比例,那么每个精灵都应该使用与它们各自的源文件相同的测量值进行渲染。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多