- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
// to enable/disable caching
export let nocache = "";
// baseURL
export let baseURL = {};
/**
* crossOrigin attribute to configure the CORS requests for Image and Video data element.
* By default (that is, when the attribute is not specified), CORS is not used at all.
* The "anonymous" keyword means that there will be no exchange of user credentials via cookies,
* client-side SSL certificates or HTTP authentication as described in the Terminology section of the CORS specification.<br>
* @type {string}
* @name crossOrigin
* @default undefined
* @memberof loader
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes
* @example
* // allow for cross-origin texture loading
* me.loader.crossOrigin = "anonymous";
*
* // set all ressources to be loaded
* me.loader.preload(game.resources, () => this.loaded());
*/
export let crossOrigin;
/**
* indicates whether or not cross-site Access-Control requests should be made using credentials such as cookies,
* authorization headers or TLS client certificates. Setting withCredentials has no effect on same-site requests.
* @public
* @type {boolean}
* @name withCredentials
* @default false
* @memberof loader
* @see https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials
* @example
* // enable withCredentials
* me.loader.withCredentials = true;
*
* // set all ressources to be loaded
* me.loader.preload(game.resources, () => this.loaded());
*/
export let withCredentials = false;
/**
* enable the nocache mechanism
* @ignore
*/
export function setNocache(enable = false) {
nocache = enable ? "?" + ~~(Math.random() * 10000000) : "";
}
/**
* change the default baseURL for the given asset type.<br>
* (this will prepend the asset URL and must finish with a '/')
* @name setBaseURL
* @memberof loader
* @public
* @param {string} type - "*", "audio", "video", "binary", "image", "json", "js", "tmx", "tsx"
* @param {string} [url="./"] - default base URL
* @example
* // change the base URL relative address for audio assets
* me.loader.setBaseURL("audio", "data/audio/");
* // change the base URL absolute address for all object types
* me.loader.setBaseURL("*", "http://myurl.com/")
*/
export function setBaseURL(type, url) {
if (type !== "*") {
baseURL[type] = url;
} else {
// "wildcards"
baseURL["audio"] = url;
baseURL["video"] = url;
baseURL["binary"] = url;
baseURL["image"] = url;
baseURL["json"] = url;
baseURL["js"] = url;
baseURL["tmx"] = url;
baseURL["tsx"] = url;
// XXX ?
//baseURL["fontface"] = url;
}
}