首页 > 解决方案 > 为什么 Phaser 3 中的图像没有变化?

问题描述

我尝试为我的游戏背景加载图像。

let gameState = {};

function preload() {
  this.load.image('background', 'assets/background.png');
}

function create() {
  gameState.background = this.add.tileSprite(480, 270, 'background').setScale(0.5);
}

function update() {

}

let config = {
  type: Phaser.AUTO,
  width: 960,
  height: 540,
  physics: {
    default: 'arcade',
    arcade: {
      gravity: { y: 500 },
      debug: false
    }
  },
  scene: {
    preload,
    create,
    update
  }
};

let game = new Phaser.Game(config);

但是,如果我删除加载和添加图像的行,即使我没有在代码中的任何地方提到图像,图像仍然会留在屏幕上。

如何删除图像?

标签: javascripthtmlbrowserserverphaser-framework

解决方案


推荐阅读