我在和Phaser做一个游戏,我试着把瓷砖组合在一起 按如下方式渲染它们:
我的代码是:
let gameScene = new Phaser.Scene('Game');
gameScene.preload = function() {
this.load.image('background', 'assets/backgrounds/beach/game_background_1.png');
this.load.image('tile', 'assets/images/tile.png');
}
gameScene.create = function() {
let bg = this.add.sprite(0, 0, 'background').setOrigin(0, 0);
this.tiles = this.add.group({
key: 'tile',
repeat: 5,
setXY: {
x: 150,
y: this.sys.game.config.height - 80,
stepX: 150,
stepY: this.sys.game.config.height - 80,
}
});
Phaser.Actions.ScaleXY(this.tiles.getChildren(), -0.5, -0.5);
}
gameScene.update = function() {
}
教程中的代码:
gameScene.preload = function(){
// load images
...
...
this.load.image('enemy', 'assets/dragon.png');
...
};
gameScene.create = function() {
this.enemies = this.add.group({
key: 'enemy',
repeat: 5,
setXY: {
x: 90,
y: 100,
stepX: 80,
stepY: 20
}
});
Phaser.Actions.ScaleXY(this.enemies.getChildren(), -0.4, -0.4);
this.add.group({})
在教程中运行良好,但当我在我的游戏中使用它时,我只得到1个瓷砖渲染.这是怎么回事?