如何将位图数据修复到 Phaser 中的相机?

How can I fix bitmapdata to the camera in Phaser?

我在 Phaser 中遇到位图数据和相机的问题。

我将移动相机作为我游戏的一部分,因为它是一款卷轴游戏。我正在使用位图数据绘制健康栏,但它一直在屏幕外滚动。 :/ 到目前为止我已经尝试过:

• 将 fixedToCamera 属性 设置为 true

• 使用移动 属性 使其随着滚动

一起移动

• 制作精灵并将位图数据添加到它作为子画面并将 fixedToCamera 属性 设置为 true

我将位图数据添加到精灵的代码:

bitmap = Game.make.bitmapData(800, 100)
bitmap.addToWorld(0, 0)
bitmapSprite = Game.add.sprite(0, 0)
bitmapSprite.addChild(bitmap)

我收到以下错误:

Uncaught TypeError: this.children[t].updateTransform is not a function
    at i.Sprite.s.DisplayObjectContainer.updateTransform (phaser.min.js:3)
    at i.World.s.DisplayObjectContainer.updateTransform (phaser.min.js:3)
    at i.Stage.updateTransform (phaser.min.js:3)
    at i.Game.updateLogic (phaser.min.js:3)
    at i.Game.update (phaser.min.js:3)
    at i.RequestAnimationFrame.updateRAF (phaser.min.js:3)
    at window.requestAnimationFrame.forceSetTimeOut._onLoop (phaser.min.js:3)

尝试这样做:

bitmap = game.add.bitmapData(800, 100);
bitmapSprite = game.add.sprite(0, 0, bitmap);
bitmapSprite.fixedToCamera = true;

这是official example for bitmapdata sprites.