-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathSpineLoader.ts
41 lines (37 loc) · 1.36 KB
/
SpineLoader.ts
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
module PhaserSpine {
/**
* Supporting class to load images from spine atlases as per spine spec.
*
* @class SpineTextureLoader
* @uses EventTarget
* @constructor
* @param basePath {String} Tha base path where to look for the images to be loaded
* @param crossorigin {Boolean} Whether requests should be treated as crossorigin
*/
export class SpineTextureLoader {
private game: Phaser.Game;
constructor(game: Phaser.Game) {
this.game = game;
}
/**
* Starts loading a base texture as per spine specification
*
* @method load
* @param page {spine.AtlasPage} Atlas page to which texture belongs
* @param file {String} The file to load, this is just the file path relative to the base path configured in the constructor
*/
public load = function (page: any, file: string, atlas: spine.Atlas) {
var image = this.game.make.image(0, 0, file);
page.rendererObject = image.texture.baseTexture;
};
/**
* Unloads a previously loaded texture as per spine specification
*
* @method unload
* @param texture {BaseTexture} Texture object to destroy
*/
public unload = function (texture: PIXI.BaseTexture) {
texture.destroy();
};
}
}