我正在 Phaser 2 CE 中编写游戏,因此实际代码如下所示https://stackoverflow.com/a/50300726/2107253但是当我在移动设备或桌面上打开游戏时,图像不会显示在中心,它是隐藏的
var game = new Phaser.Game(640, 480, Phaser.AUTO, 'game', { preload: preload, create: create, update: update });
var sprite;
function preload () {
// This is equivalent to <https://examples.phaser.io/assets/>.
this.load.image('dude', 'assets/sprites/phaser-dude.png');
}
function create() {
sprite = game.add.sprite(game.world.centerX, game.world.centerY, 'dude');
sprite.inputEnabled = true;
sprite.events.onInputDown.add(myHandler, this);
}
function myHandler() {
sprite.x += 10;
}
function update() {
}