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

Commit

Permalink
Version 1.5.0
Browse files Browse the repository at this point in the history
- Add on error condition
- Add error expression
- Add set speed action (scales animation speed)
- Add default mix interval property
  • Loading branch information
MikalDev committed Jul 18, 2020
1 parent 9378468 commit 2bd8067
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 14 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ Useful for Dragon Bones Spine JSON export and earlier Spine versions.
## Current supported features
- Load Spine json, atlas and pngs.
- Select starting skin, skeleton, animation
- Dynamically set existing skin define in JSON
- Mesh Deformation
- Dynamically set existing skin defined in JSON
- Mesh Deformations
- Animation set, play, pause, trigger on animation complete.
- Animation finished, animation playing conditions.
- Default mix interval for blending animations.
- Dynamic animation speed control.

## Wishlist
- Mixing for blending Animation
- Events
- Dynamic attachment changing for skin attachments.
- Events to trigger C3 triggers.
- Mixing for indiviual animation pairs.
Binary file added dist/Spine-v1.5.0.c3addon
Binary file not shown.
Binary file modified sample_projects/SpinePluginTest.c3p
Binary file not shown.
25 changes: 25 additions & 0 deletions src/aces.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
"type": "string"
}
]
},
{
"id": "on-error",
"scriptName": "OnError",
"isTrigger": true
}
],
"actions": [
Expand Down Expand Up @@ -89,6 +94,18 @@
"scriptName": "UpdateBounds",
"highlight": true,
"params": []
},
{
"id": "set-animation-speed",
"scriptName": "SetAnimationSpeed",
"highlight": true,
"params": [
{
"id": "speed",
"type": "number",
"initialValue": 1.0
}
]
}
],
"expressions": [
Expand Down Expand Up @@ -165,6 +182,14 @@
"type": "number"
}
]
},
{
"id": "spine-error",
"expressionName": "Error",
"scriptName": "Error",
"highlight": false,
"returnType": "string",
"params": []
}
]
}
Expand Down
8 changes: 4 additions & 4 deletions src/addon.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"type": "plugin",
"name": "Spine",
"id": "Gritsenko_Spine",
"version": "1.4.6.0",
"author": "Igor Gritsenko",
"website": "https://www.gritsenko.biz",
"documentation": "https://www.construct.net",
"version": "1.5.0",
"author": "Igor Gritsenko and Mikal",
"website": "https://gritsenko.github.io/c3_spine_plugin",
"documentation": "https://gritsenko.github.io/c3_spine_plugin",
"description": "Unofficial spine addon - render to texture",
"editor-scripts": [
"plugin.js",
Expand Down
5 changes: 4 additions & 1 deletion src/c3runtime/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@

UpdateBounds() {
this.updateBounds();
}
},
SetAnimationSpeed(speed){
this.animationSpeed = speed;
},
};
}
3 changes: 3 additions & 0 deletions src/c3runtime/conditions.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

IsAnimationPlaying(animationName) {
return this.animationName == animationName;
},
OnError() {
return true;
}

};
Expand Down
4 changes: 4 additions & 0 deletions src/c3runtime/expressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@

AnimationName(index){
return this.animationNames[index];
},

Error(){
return this.spineError;
}


Expand Down
14 changes: 11 additions & 3 deletions src/c3runtime/instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
this.skeletonScale = properties[6];
this.premultipliedAlpha = properties[7];
this.collisionsEnabled = properties[8];
this.defaultMix = properties[9];
}

this.isMirrored = false;
Expand All @@ -51,6 +52,8 @@
this.spineFB = null
this.initSpineInProgress = false;
this.completeAnimationName = ""
this.spineError = null
this.animationSpeed = 1.0

const wi = this.GetWorldInfo();
// Enable collisions based on property, add ACEs if needed
Expand Down Expand Up @@ -215,9 +218,12 @@

skeleton.setSkin(subskin);

console.log("Loading state");
if (this.debug) console.log("Loading state");

var state = new spine.AnimationState(new spine.AnimationStateData(skeletonData));
let stateData = new spine.AnimationStateData(skeletonData);
stateData.defaultMix = this.defaultMix;

var state = new spine.AnimationState(stateData);
state.setAnimation(0, animationName, true);
state.apply(skeleton);
skeleton.updateWorldTransform();
Expand Down Expand Up @@ -293,6 +299,8 @@
} catch (ex) {
console.error(ex);
alert(ex + "\n\n available animations: \n" + this.animationNames.join("\n"));
this.spineError = ex + "\n\n available animations: \n" + this.animationNames.join("\n");
this.Trigger(C3.Plugins.Gritsenko_Spine.Cnds.OnError);
}
}

Expand Down Expand Up @@ -466,7 +474,7 @@
if (!this.IsSpineReady()) {
return;
}
const delta = this._runtime.GetDt();
const delta = this._runtime.GetDt() * this.animationSpeed;
var active = this.skeletonInfo;
const state = this.skeletonInfo.state;

Expand Down
25 changes: 25 additions & 0 deletions src/lang/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
"collisions": {
"name": "Enable collisions",
"desc": "Whether the object will register collision events or not."
},
"default-mix": {
"name": "Default mix",
"desc": "Set default mix time between animations (s)"
}
},
"aceCategories": {
Expand Down Expand Up @@ -81,6 +85,11 @@
"desc": "Animation name"
}
}
},
"on-error": {
"list-name": "On error",
"display-text": "On error",
"description": "Triggered on any spine error, error message in error expression."
}
},
"actions": {
Expand Down Expand Up @@ -138,6 +147,17 @@
"display-text": "Update spine Bounds",
"description": "Fit spine model to bounds if c3 object",
"params": { }
},
"set-animation-speed": {
"list-name": "Set animation speed",
"display-text": "Set animation speed {0}x",
"description": "Set animation speed. 1 = 1x speed, 2 = 2x speed, 0.5 = 1/2x speed.",
"params": {
"speed": {
"name": "Speed",
"desc": "Scaling animation speed."
}
}
}
},
"expressions": {
Expand Down Expand Up @@ -190,6 +210,11 @@
"desc": "Animation index"
}
}
},
"spine-error": {
"description": "Error message for on error trigger.",
"translated-name": "Error",
"params": {}
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions 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.4.6.0";
const PLUGIN_VERSION = "1.5.0";
const PLUGIN_CATEGORY = "general";

const PLUGIN_CLASS = SDK.Plugins.Gritsenko_Spine = class SpinePlugin extends SDK.IPluginBase {
Expand Down Expand Up @@ -55,7 +55,8 @@
new SDK.PluginProperty("text", "skeleton", ""),
new SDK.PluginProperty("float", "scale", 1),
new SDK.PluginProperty("check", "pre-mult-alpha", false),
new SDK.PluginProperty("check", "collisions", true)
new SDK.PluginProperty("check", "collisions", true),
new SDK.PluginProperty("float", "default-mix", 0.0)
]);
SDK.Lang.PopContext(); //.properties
SDK.Lang.PopContext();
Expand Down

0 comments on commit 2bd8067

Please sign in to comment.