mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[ts] Added ability to specify multi-page atlas images in widget. See README for details. Closes #786.
This commit is contained in:
parent
f4a65fdcd4
commit
52d60bae82
@ -160,6 +160,7 @@ The configuration object has the following fields:
|
||||
* `atlas`: required, path to the `.atlas` file, absolute or relative, e.g. "assets/animation.atlas"
|
||||
* `animation`: required, the name of the animation to play back
|
||||
* `imagesPath`: optional, the location of images on the server to load atlas pages from. If omitted, atlas `.png` page files are loaded relative to the `.atlas` file.
|
||||
* `atlasPages`: optional, the list of atlas page images, e.g. `atlasPages: ["assets/page1.png", "assets/page2.png"]` when using code, or `data-atlas-pages="assets/page1.png,assets/page2.png"` on case of HTML instantiation. Use this if you have a multi-page atlas. If ommited, only one atlas page image is loaded based on the atlas file name, replacing `.atlas` with `.png`.
|
||||
* `skin`: optional, the name of the skin to use. Defaults to `default` if omitted.
|
||||
* `loop`: optional, whether to loop the animation or not. Defaults to `true` if omitted.
|
||||
* `scale`: optional, the scaling factor to apply when loading the `.json` file. Defaults to `1` if omitted. Irrelevant if `data-fit-to-canavs` is `true`.
|
||||
|
||||
1
spine-ts/build/spine-all.d.ts
vendored
1
spine-ts/build/spine-all.d.ts
vendored
@ -1543,6 +1543,7 @@ declare module spine {
|
||||
atlas: string;
|
||||
animation: string;
|
||||
imagesPath: string;
|
||||
atlasPages: string[];
|
||||
skin: string;
|
||||
loop: boolean;
|
||||
scale: number;
|
||||
|
||||
@ -7899,7 +7899,14 @@ var spine;
|
||||
var assets = this.assetManager = new spine.webgl.AssetManager(gl);
|
||||
assets.loadText(config.atlas);
|
||||
assets.loadText(config.json);
|
||||
if (config.atlasPages == null) {
|
||||
assets.loadTexture(config.atlas.replace(".atlas", ".png"));
|
||||
}
|
||||
else {
|
||||
for (var i = 0; i < config.atlasPages.length; i++) {
|
||||
assets.loadTexture(config.atlasPages[i]);
|
||||
}
|
||||
}
|
||||
requestAnimationFrame(function () { _this.load(); });
|
||||
}
|
||||
SpineWidget.prototype.validateConfig = function (config) {
|
||||
@ -8082,6 +8089,8 @@ var spine;
|
||||
config.animation = widget.getAttribute("data-animation");
|
||||
if (widget.getAttribute("data-images-path"))
|
||||
config.imagesPath = widget.getAttribute("data-images-path");
|
||||
if (widget.getAttribute("data-atlas-pages"))
|
||||
config.atlasPages = widget.getAttribute("data-atlas-pages").split(",");
|
||||
if (widget.getAttribute("data-skin"))
|
||||
config.skin = widget.getAttribute("data-skin");
|
||||
if (widget.getAttribute("data-loop"))
|
||||
|
||||
File diff suppressed because one or more lines are too long
1
spine-ts/build/spine-widget.d.ts
vendored
1
spine-ts/build/spine-widget.d.ts
vendored
@ -1473,6 +1473,7 @@ declare module spine {
|
||||
atlas: string;
|
||||
animation: string;
|
||||
imagesPath: string;
|
||||
atlasPages: string[];
|
||||
skin: string;
|
||||
loop: boolean;
|
||||
scale: number;
|
||||
|
||||
@ -7478,7 +7478,14 @@ var spine;
|
||||
var assets = this.assetManager = new spine.webgl.AssetManager(gl);
|
||||
assets.loadText(config.atlas);
|
||||
assets.loadText(config.json);
|
||||
if (config.atlasPages == null) {
|
||||
assets.loadTexture(config.atlas.replace(".atlas", ".png"));
|
||||
}
|
||||
else {
|
||||
for (var i = 0; i < config.atlasPages.length; i++) {
|
||||
assets.loadTexture(config.atlasPages[i]);
|
||||
}
|
||||
}
|
||||
requestAnimationFrame(function () { _this.load(); });
|
||||
}
|
||||
SpineWidget.prototype.validateConfig = function (config) {
|
||||
@ -7661,6 +7668,8 @@ var spine;
|
||||
config.animation = widget.getAttribute("data-animation");
|
||||
if (widget.getAttribute("data-images-path"))
|
||||
config.imagesPath = widget.getAttribute("data-images-path");
|
||||
if (widget.getAttribute("data-atlas-pages"))
|
||||
config.atlasPages = widget.getAttribute("data-atlas-pages").split(",");
|
||||
if (widget.getAttribute("data-skin"))
|
||||
config.skin = widget.getAttribute("data-skin");
|
||||
if (widget.getAttribute("data-loop"))
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -80,7 +80,13 @@ module spine {
|
||||
let assets = this.assetManager = new spine.webgl.AssetManager(gl);
|
||||
assets.loadText(config.atlas);
|
||||
assets.loadText(config.json);
|
||||
if (config.atlasPages == null) {
|
||||
assets.loadTexture(config.atlas.replace(".atlas", ".png"));
|
||||
} else {
|
||||
for (let i = 0; i < config.atlasPages.length; i++) {
|
||||
assets.loadTexture(config.atlasPages[i]);
|
||||
}
|
||||
}
|
||||
requestAnimationFrame(() => { this.load(); });
|
||||
}
|
||||
|
||||
@ -264,6 +270,7 @@ module spine {
|
||||
config.json = widget.getAttribute("data-json");
|
||||
config.animation = widget.getAttribute("data-animation");
|
||||
if (widget.getAttribute("data-images-path")) config.imagesPath = widget.getAttribute("data-images-path");
|
||||
if (widget.getAttribute("data-atlas-pages")) config.atlasPages = widget.getAttribute("data-atlas-pages").split(",");
|
||||
if (widget.getAttribute("data-skin")) config.skin = widget.getAttribute("data-skin");
|
||||
if (widget.getAttribute("data-loop")) config.loop = widget.getAttribute("data-loop") === "true";
|
||||
if (widget.getAttribute("data-scale")) config.scale = parseFloat(widget.getAttribute("data-scale"));
|
||||
@ -303,6 +310,7 @@ module spine {
|
||||
atlas: string;
|
||||
animation: string;
|
||||
imagesPath: string;
|
||||
atlasPages: string[];
|
||||
skin = "default";
|
||||
loop = true;
|
||||
scale = 1.0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user