我正在使用一些我想在实际游戏中按比例缩小的大图像在 Phaser 中制作游戏:
create() {
//Create the sprite group and scale it down to 30%
this.pieces = this.add.group(undefined, "pieces", true);
this.pieces.scale.x = 0.3;
this.pieces.scale.y = 0.3;
//Add the players to the middle of the stage and add them to the 'pieces' group
var middle = new Phaser.Point( game.stage.width/2, game.stage.height/2);
var player_two = this.add.sprite(middle.x - 50, middle.y, 'image1', undefined, this.pieces);
var player_one = this.add.sprite(middle.x, middle.y-50, 'image2', undefined, this.pieces);
}
然而,由于精灵的大小是按比例缩放的,它们的起始位置也是按比例缩放的,所以它们出现在舞台中间,只出现在到中间距离的 30% 处。
如何缩放精灵图像而不影响它们的位置?
(代码顺便在 Typescript 中,但我认为这个特定的示例也是 javascript,所以这可能无关紧要)