JavaScript中的this.load.setBaseURL

问题描述

我正在尝试学习javascript和phaserjs,并在index.html中找到一行内容: this.load.setBaseURL('http://labs.phaser.io'); 有人知道setBaseURL的功能是什么? 谢谢

解决方法

documentation这样说,

If you want to append a URL before the path of any asset you can set this here.

Useful if allowing the asset base url to be configured outside of the game code.

Once a base URL is set it will affect every file loaded by the Loader from that point on. It does not change any file already being loaded. To reset it,call this method with no arguments.

因此,它将更改声明后要加载的资产/文件的基本路径。