Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #32 from gritsenko/add-runtime-skins
Browse files Browse the repository at this point in the history
Add runtime create and add skins
  • Loading branch information
MikalDev authored Sep 13, 2020
2 parents 579619d + cb2f7a0 commit f322a68
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 4 deletions.
Binary file added dist/Spine-v1.13.0.c3addon
Binary file not shown.
Binary file added sample_projects/SpineMixandMatch.c3p
Binary file not shown.
37 changes: 37 additions & 0 deletions src/aces.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,43 @@
"type": "string"
}
]
},
{
"id": "create-custom-skin",
"scriptName": "CreateCustomSkin",
"highlight": false,
"params": [
{
"id": "skin-name",
"type": "string"
}
]
},
{
"id": "add-custom-skin",
"scriptName": "AddCustomSkin",
"highlight": false,
"params": [
{
"id": "skin-name",
"type": "string"
},
{
"id": "add-skin-name",
"type": "string"
}
]
},
{
"id": "set-custom-skin",
"scriptName": "SetCustomSkin",
"highlight": false,
"params": [
{
"id": "skin-name",
"type": "string"
}
]
}
],
"expressions": [
Expand Down
2 changes: 1 addition & 1 deletion src/addon.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "plugin",
"name": "Spine",
"id": "Gritsenko_Spine",
"version": "1.12.1",
"version": "1.13.0",
"author": "Mikal and Igor Gritsenko",
"website": "https://gritsenko.github.io/c3_spine_plugin",
"documentation": "https://gritsenko.github.io/c3_spine_plugin",
Expand Down
29 changes: 29 additions & 0 deletions src/c3runtime/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,35 @@
const skeleton = this.skeletonInfo.skeleton;

skeleton.setAttachment(slotName,attachmentName);
},

CreateCustomSkin(skinName)
{
const skeleton = this.skeletonInfo.skeleton;

this.customSkins[skinName] = new spine.Skin(skinName);
},

AddCustomSkin(skinName,addSkinName)
{
const skeleton = this.skeletonInfo.skeleton;

if (this.customSkins[skinName])
{
this.customSkins[skinName].addSkin(skeleton.data.findSkin(addSkinName));
} else
{
console.log('[Spine] AddCustomSkin, error - custom skin does not exist',skinName);
}
},

SetCustomSkin(skinName)
{
this.skinName = skinName
const skeleton = this.skeletonInfo.skeleton;
this.customSkins[this.skinName]
skeleton.setSkin(this.customSkins[this.skinName]);
skeleton.setSlotsToSetupPose();
}
};
}
6 changes: 4 additions & 2 deletions src/c3runtime/instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
this.skeletonInfo = null;
this.renderer = null;
this.gl = null;
// this._sdkType._skeletonInstances[this.GetInstance().GetUID()] = {'initialized' : false};
// super(inst, DOM_COMPONENT_ID);
this.uid = this.GetInstance().GetUID();
this.customSkins = {};

this.atlasPath = "";

Expand Down Expand Up @@ -383,6 +383,8 @@
this.skeletonRenderQuality = null;
this.textureWidth = null;
this.textureHeight = null;
this.uid = null;
this.customSkins = null;
}

Tick() {
Expand Down
37 changes: 37 additions & 0 deletions src/lang/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,43 @@
"desc": "Region name"
}
}
},
"create-custom-skin": {
"list-name": "Create custom skin",
"display-text": "Create custom skin {0}",
"description": "Create custom skin.",
"params": {
"skin-name": {
"name": "Skin name",
"desc": "Skin name"
}
}
},
"add-custom-skin": {
"list-name": "Add custom skin",
"display-text": "Add skin {1} to custom skin {0}",
"description": "Add skin to custom skin.",
"params": {
"skin-name": {
"name": "Custom skin name",
"desc": "Custom skin name"
},
"add-skin-name": {
"name": "Add skin name",
"desc": "Skin name to add to custom skin."
}
}
},
"set-custom-skin": {
"list-name": "Set custom skin",
"display-text": "Set custom skin {0}",
"description": "Set custom skin.",
"params": {
"skin-name": {
"name": "Skin name",
"desc": "Skin name"
}
}
}
},
"expressions": {
Expand Down
2 changes: 1 addition & 1 deletion src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{

const PLUGIN_ID = "Gritsenko_Spine";
const PLUGIN_VERSION = "1.12.1";
const PLUGIN_VERSION = "1.13.0";
const PLUGIN_CATEGORY = "general";

const PLUGIN_CLASS = SDK.Plugins.Gritsenko_Spine = class SpinePlugin extends SDK.IPluginBase {
Expand Down

0 comments on commit f322a68

Please sign in to comment.