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

Commit

Permalink
1.16.2 Change Set Anim w/ start to not fire past events.
Browse files Browse the repository at this point in the history
Change behavior of *Set Animation w/ starting time* to not trigger events if the events were before the starting time.
  • Loading branch information
MikalDev committed Oct 1, 2020
1 parent 723ae3b commit 0e3030a
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 27 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Add-on based on **Mikal's** sample from this thread:
[https://www.construct.net/en/forum/construct-3/general-discussion-7/spine-animation-js-template-145940 ](https://www.construct.net/en/forum/construct-3/general-discussion-7/spine-animation-js-template-145940)

## Downloads
[Add-on](https://github.com/gritsenko/c3_spine_plugin/releases/download/1.16.1/Spine-v1.16.1.c3addon)
[Add-on](https://github.com/gritsenko/c3_spine_plugin/releases/download/1.16.2/Spine-v1.16.2.c3addon)

[Previous Add-on Versions](https://github.com/gritsenko/c3_spine_plugin/tree/master/dist)

Expand Down Expand Up @@ -84,6 +84,7 @@ Useful for Dragon Bones Spine JSON export and earlier Spine versions.
## Wishlist
- Preview Spine render in editor (dependent on C3 editor SDK updates)
## Release notes
- 1.16.2 Change behavior of *Set Animation w/ starting time* to not trigger events if the events were before the starting time.
- 1.16.1 Bug fix for slot color (handle reset and new skin properly, only apply dark color if Tint Black is set in Spine project for slot).
- 1.16.0 Add Set slot dark color, Apply Slot color, Reset Slot color. Add Set animation time and starting point of Set animation (beginning, current time, current ratio). Deprecated set color attachment (did not support dark color).
- 1.15.2 Add project sampling support to Spine C3 texture.
Expand Down
Binary file added dist/Spine-v1.16.2.c3addon
Binary file not shown.
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.16.1",
"version": "1.16.2",
"author": "Mikal and Igor Gritsenko",
"website": "https://gritsenko.github.io/c3_spine_plugin",
"documentation": "https://gritsenko.github.io/c3_spine_plugin",
Expand Down
64 changes: 40 additions & 24 deletions src/c3runtime/instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@
}

updateCurrentAnimation(loop,start) {

if (!this.skeletonInfo) return;
if (!this.skeletonInfo.skeleton) return;

try {
const state = this.skeletonInfo.state;
const skeleton = this.skeletonInfo.skeleton;
Expand All @@ -291,23 +295,14 @@
if (track) {
// calculate ratio and time
currentTime = track.trackTime;
currentRatio = (track.animationLast+track.trackTime-track.trackLast)/(track.animationEnd-track.animationStart);
console.log('[Spine] currentTime', currentTime, currentRatio);
if (track.animationEnd != track.animationStart && track.animationEnd > track.animationStart)
{
currentRatio = (track.animationLast+track.trackTime-track.trackLast)/(track.animationEnd-track.animationStart);
}
// console.log('[Spine] currentTime', currentTime, currentRatio);
}

state.setAnimation(0, this.animationName, loop);

state.tracks[0].listener = {
complete: (trackEntry, count) => {
this.completeAnimationName = this.animationName;
this.Trigger(C3.Plugins.Gritsenko_Spine.Cnds.OnAnimationFinished);
this.Trigger(C3.Plugins.Gritsenko_Spine.Cnds.OnAnyAnimationFinished);
},
event: (trackIndex, event) => {
this.completeEventName = event.data.name;
this.Trigger(C3.Plugins.Gritsenko_Spine.Cnds.OnEvent);
}
};

switch (start)
{
Expand All @@ -317,16 +312,37 @@
default: break;
}

state.apply(skeleton);



console.log('[Spine] trackTime 0', state.tracks[0].trackTime);

console.log('[Spine] trackTime 1', state.tracks[0].trackTime);

console.log('[Spine] track:', state.tracks[0]);

if (start == 0 || (start == 2 && currentRatio == 0))
// If starting from beginning or 0 ratio add listners so they'll trigger at 0
{
state.tracks[0].listener = {
complete: (trackEntry, count) => {
this.completeAnimationName = this.animationName;
this.Trigger(C3.Plugins.Gritsenko_Spine.Cnds.OnAnimationFinished);
this.Trigger(C3.Plugins.Gritsenko_Spine.Cnds.OnAnyAnimationFinished);
},
event: (trackIndex, event) => {
this.completeEventName = event.data.name;
this.Trigger(C3.Plugins.Gritsenko_Spine.Cnds.OnEvent);
}
};
state.apply(skeleton);
} else
// If starting later, apply time, then enable listeners so they do not trigger on past events
{
state.apply(skeleton);
state.tracks[0].listener = {
complete: (trackEntry, count) => {
this.completeAnimationName = this.animationName;
this.Trigger(C3.Plugins.Gritsenko_Spine.Cnds.OnAnimationFinished);
this.Trigger(C3.Plugins.Gritsenko_Spine.Cnds.OnAnyAnimationFinished);
},
event: (trackIndex, event) => {
this.completeEventName = event.data.name;
this.Trigger(C3.Plugins.Gritsenko_Spine.Cnds.OnEvent);
}
};
}
} catch (ex) {
console.error(ex);
alert(ex + "\n\n available animations: \n" + this.animationNames.join("\n"));
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.16.1";
const PLUGIN_VERSION = "1.16.2";
const PLUGIN_CATEGORY = "general";

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

0 comments on commit 0e3030a

Please sign in to comment.