mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-06 18:56:54 +08:00
Pull addAnimation from #2949.
This commit is contained in:
parent
19396f435c
commit
281d36e634
@ -61,9 +61,11 @@ export class AssetLoader {
|
|||||||
const blob = projectFile.GetBlob();
|
const blob = projectFile.GetBlob();
|
||||||
const content = await blob.text();
|
const content = await blob.text();
|
||||||
|
|
||||||
|
const path = projectFile.GetPath();
|
||||||
|
const basePath = path.substring(0, path.lastIndexOf("/") + 1);
|
||||||
const textureAtlas = new TextureAtlas(content);
|
const textureAtlas = new TextureAtlas(content);
|
||||||
await Promise.all(textureAtlas.pages.map(async page => {
|
await Promise.all(textureAtlas.pages.map(async page => {
|
||||||
const texture = await this.loadSpineTextureEditor(page.name, page.pma, instance);
|
const texture = await this.loadSpineTextureEditor(basePath + page.name, page.pma, instance);
|
||||||
if (texture) {
|
if (texture) {
|
||||||
const spineTexture = new C3TextureEditor(texture, renderer, page);
|
const spineTexture = new C3TextureEditor(texture, renderer, page);
|
||||||
page.setTexture(spineTexture);
|
page.setTexture(spineTexture);
|
||||||
@ -112,9 +114,10 @@ export class AssetLoader {
|
|||||||
const content = await instance.assets.fetchText(fullPath);
|
const content = await instance.assets.fetchText(fullPath);
|
||||||
if (!content) return null;
|
if (!content) return null;
|
||||||
|
|
||||||
|
const basePath = path.substring(0, path.lastIndexOf("/") + 1);
|
||||||
const textureAtlas = new TextureAtlas(content);
|
const textureAtlas = new TextureAtlas(content);
|
||||||
await Promise.all(textureAtlas.pages.map(async page => {
|
await Promise.all(textureAtlas.pages.map(async page => {
|
||||||
const texture = await this.loadSpineTextureRuntime(page.name, page.pma, instance);
|
const texture = await this.loadSpineTextureRuntime(basePath + page.name, page.pma, instance);
|
||||||
if (texture) {
|
if (texture) {
|
||||||
const spineTexture = new C3Texture(texture, renderer, page);
|
const spineTexture = new C3Texture(texture, renderer, page);
|
||||||
page.setTexture(spineTexture);
|
page.setTexture(spineTexture);
|
||||||
|
|||||||
@ -31,11 +31,6 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"actions": [
|
"actions": [
|
||||||
{
|
|
||||||
"id": "do-alert",
|
|
||||||
"scriptName": "Alert",
|
|
||||||
"highlight": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"id": "set-skin",
|
"id": "set-skin",
|
||||||
"scriptName": "SetSkin",
|
"scriptName": "SetSkin",
|
||||||
@ -50,7 +45,7 @@
|
|||||||
{
|
{
|
||||||
"id": "set-animation",
|
"id": "set-animation",
|
||||||
"scriptName": "SetAnimation",
|
"scriptName": "SetAnimation",
|
||||||
"highlight": false,
|
"highlight": true,
|
||||||
"params": [
|
"params": [
|
||||||
{
|
{
|
||||||
"id": "track",
|
"id": "track",
|
||||||
@ -65,6 +60,29 @@
|
|||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "add-animation",
|
||||||
|
"scriptName": "AddAnimation",
|
||||||
|
"highlight": true,
|
||||||
|
"params": [
|
||||||
|
{
|
||||||
|
"id": "track",
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "animation",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "loop",
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "delay",
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"expressions": [
|
"expressions": [
|
||||||
|
|||||||
@ -15,6 +15,10 @@ C3.Plugins.EsotericSoftware_SpineConstruct3.Acts =
|
|||||||
|
|
||||||
SetAnimation (this: SDKInstanceClass, track: number, animation: string, loop = false) {
|
SetAnimation (this: SDKInstanceClass, track: number, animation: string, loop = false) {
|
||||||
this.setAnimation(track, animation, loop);
|
this.setAnimation(track, animation, loop);
|
||||||
|
},
|
||||||
|
|
||||||
|
AddAnimation (this: SDKInstanceClass, track: number, animation: string, loop = false, delay = 0) {
|
||||||
|
this.addAnimation(track, animation, loop, delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -144,6 +144,32 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public addAnimation (track: number, animation: string, loop = false, delay = 0) {
|
||||||
|
const trackEntry = this.state?.addAnimation(track, animation, loop, delay);
|
||||||
|
if (!trackEntry) return;
|
||||||
|
|
||||||
|
trackEntry.listener = {
|
||||||
|
start: () => {
|
||||||
|
this.triggetAnimationEvent("start", track, animation);
|
||||||
|
},
|
||||||
|
dispose: () => {
|
||||||
|
this.triggetAnimationEvent("dispose", track, animation);
|
||||||
|
},
|
||||||
|
event: (_, event) => {
|
||||||
|
this.triggetAnimationEvent("event", track, animation, event);
|
||||||
|
},
|
||||||
|
interrupt: () => {
|
||||||
|
this.triggetAnimationEvent("interrupt", track, animation);
|
||||||
|
},
|
||||||
|
end: () => {
|
||||||
|
this.triggetAnimationEvent("end", track, animation);
|
||||||
|
},
|
||||||
|
complete: () => {
|
||||||
|
this.triggetAnimationEvent("complete", track, animation);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public setSkin (skins: string[]) {
|
public setSkin (skins: string[]) {
|
||||||
this.propSkin = skins;
|
this.propSkin = skins;
|
||||||
this._setSkin();
|
this._setSkin();
|
||||||
|
|||||||
@ -61,7 +61,6 @@ class SpineC3PluginInstance extends SDK.IWorldInstanceBase {
|
|||||||
|
|
||||||
OnCreate () {
|
OnCreate () {
|
||||||
this._inst.SetPropertyValue(PLUGIN_CLASS.PROP_BOUNDS_PROVIDER_MOVE, false);
|
this._inst.SetPropertyValue(PLUGIN_CLASS.PROP_BOUNDS_PROVIDER_MOVE, false);
|
||||||
this._inst.GetPropertyValue(PLUGIN_CLASS.PROP_SKELETON) as number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OnPlacedInLayout () {
|
OnPlacedInLayout () {
|
||||||
|
|||||||
@ -135,6 +135,29 @@
|
|||||||
"desc": "loop"
|
"desc": "loop"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"add-animation": {
|
||||||
|
"list-name": "Add animation",
|
||||||
|
"display-text": "Add animation {1} on track {0} with loop {2} and delay {3}",
|
||||||
|
"description": "Add animation",
|
||||||
|
"params": {
|
||||||
|
"track": {
|
||||||
|
"name": "track",
|
||||||
|
"desc": "track"
|
||||||
|
},
|
||||||
|
"animation": {
|
||||||
|
"name": "animations name",
|
||||||
|
"desc": "animations name"
|
||||||
|
},
|
||||||
|
"loop": {
|
||||||
|
"name": "loop",
|
||||||
|
"desc": "loop"
|
||||||
|
},
|
||||||
|
"delay": {
|
||||||
|
"name": "delay",
|
||||||
|
"desc": "delay"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"expressions": {
|
"expressions": {
|
||||||
|
|||||||
@ -117,29 +117,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"add-animation": {
|
|
||||||
"list-name": "添加动画",
|
|
||||||
"display-text": "在轨道{0}上添加动画{1},循环{2},延迟{3}",
|
|
||||||
"description": "添加动画",
|
|
||||||
"params": {
|
|
||||||
"track": {
|
|
||||||
"name": "轨道",
|
|
||||||
"desc": "轨道"
|
|
||||||
},
|
|
||||||
"animation": {
|
|
||||||
"name": "动画名称",
|
|
||||||
"desc": "动画名称"
|
|
||||||
},
|
|
||||||
"loop": {
|
|
||||||
"name": "循环",
|
|
||||||
"desc": "循环"
|
|
||||||
},
|
|
||||||
"delay": {
|
|
||||||
"name": "延迟",
|
|
||||||
"desc": "延迟"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"set-animation": {
|
"set-animation": {
|
||||||
"list-name": "设置动画",
|
"list-name": "设置动画",
|
||||||
"display-text": "在轨道{0}上设置动画{1},循环{2}",
|
"display-text": "在轨道{0}上设置动画{1},循环{2}",
|
||||||
@ -160,6 +137,29 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"add-animation": {
|
||||||
|
"list-name": "添加动画",
|
||||||
|
"display-text": "在轨道{0}上添加动画{1},循环{2},延迟{3}",
|
||||||
|
"description": "添加动画",
|
||||||
|
"params": {
|
||||||
|
"track": {
|
||||||
|
"name": "轨道",
|
||||||
|
"desc": "轨道"
|
||||||
|
},
|
||||||
|
"animation": {
|
||||||
|
"name": "动画名称",
|
||||||
|
"desc": "动画名称"
|
||||||
|
},
|
||||||
|
"loop": {
|
||||||
|
"name": "循环",
|
||||||
|
"desc": "循环"
|
||||||
|
},
|
||||||
|
"delay": {
|
||||||
|
"name": "延迟",
|
||||||
|
"desc": "延迟"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"expressions": {
|
"expressions": {
|
||||||
"double": {
|
"double": {
|
||||||
"description": "将数字翻倍。",
|
"description": "将数字翻倍。",
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user