当Phaser.Text 元素的属性fixedToCamera 设置为true 时,如何更改它的位置。在下面的代码中,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”。因此,如果您像修改位置一样修改它,一切都会正常工作。
关于javascript - 当固定到相机时更改 Phaser.Text 的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26303755/