固定时更改Phaser.Text的位置ToCamera

Changing position of Phaser.Text when fixedToCamera

本文关键字:位置 ToCamera Text Phaser 定时      更新时间:2023-09-26

当属性fixedToCamera设置为true时,如何更改Phaser.Text元素的位置。在下面的代码中,counterText.x的值总是重置为45;

var game = new Phaser.Game(500, 500, 'phaser-example', { create: create, update: update});
var counter = 0;
function create() {
  counterText = game.add.text(45, 45, 'Text', {
    font: "26px Verdana",
    fill: "#fff"
  });
  counterText.fixedToCamera = true;
}
function update() {
 counterText.x = counter++;
}

我认为这里的问题是,当fixedToCamera为true时,Text不再使用"position",而是使用"cameraOffset"。因此,如果你像修改职位一样修改它,一切都会很好。