我正在使用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编写,所以这可能并不重要)