Skip to content

Commit 7b8f4c6

Browse files
committed
Added Events and better 'ignore if playing' handling
1 parent d43e755 commit 7b8f4c6

10 files changed

Lines changed: 354 additions & 19 deletions

File tree

plugins/spine/dist/SpinePlugin.js

Lines changed: 215 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19968,6 +19968,181 @@ var SpinePlugin = new Class({
1996819968
module.exports = SpinePlugin;
1996919969

1997019970

19971+
/***/ }),
19972+
19973+
/***/ "./events/COMPLETE_EVENT.js":
19974+
/*!**********************************!*\
19975+
!*** ./events/COMPLETE_EVENT.js ***!
19976+
\**********************************/
19977+
/*! no static exports found */
19978+
/***/ (function(module, exports) {
19979+
19980+
/**
19981+
* @author Richard Davey <rich@photonstorm.com>
19982+
* @copyright 2019 Photon Storm Ltd.
19983+
* @license {@link https://opensource.org/licenses/MIT|MIT License}
19984+
*/
19985+
19986+
/**
19987+
* The Complete Event.
19988+
*
19989+
* @event SpinePluginEvents#COMPLETE
19990+
* @since 3.19.0
19991+
*/
19992+
module.exports = 'complete';
19993+
19994+
19995+
/***/ }),
19996+
19997+
/***/ "./events/DISPOSE_EVENT.js":
19998+
/*!*********************************!*\
19999+
!*** ./events/DISPOSE_EVENT.js ***!
20000+
\*********************************/
20001+
/*! no static exports found */
20002+
/***/ (function(module, exports) {
20003+
20004+
/**
20005+
* @author Richard Davey <rich@photonstorm.com>
20006+
* @copyright 2019 Photon Storm Ltd.
20007+
* @license {@link https://opensource.org/licenses/MIT|MIT License}
20008+
*/
20009+
20010+
/**
20011+
* The Complete Event.
20012+
*
20013+
* @event SpinePluginEvents#DISPOSE
20014+
* @since 3.19.0
20015+
*/
20016+
module.exports = 'dispose';
20017+
20018+
20019+
/***/ }),
20020+
20021+
/***/ "./events/END_EVENT.js":
20022+
/*!*****************************!*\
20023+
!*** ./events/END_EVENT.js ***!
20024+
\*****************************/
20025+
/*! no static exports found */
20026+
/***/ (function(module, exports) {
20027+
20028+
/**
20029+
* @author Richard Davey <rich@photonstorm.com>
20030+
* @copyright 2019 Photon Storm Ltd.
20031+
* @license {@link https://opensource.org/licenses/MIT|MIT License}
20032+
*/
20033+
20034+
/**
20035+
* The Complete Event.
20036+
*
20037+
* @event SpinePluginEvents#END
20038+
* @since 3.19.0
20039+
*/
20040+
module.exports = 'end';
20041+
20042+
20043+
/***/ }),
20044+
20045+
/***/ "./events/EVENT_EVENT.js":
20046+
/*!*******************************!*\
20047+
!*** ./events/EVENT_EVENT.js ***!
20048+
\*******************************/
20049+
/*! no static exports found */
20050+
/***/ (function(module, exports) {
20051+
20052+
/**
20053+
* @author Richard Davey <rich@photonstorm.com>
20054+
* @copyright 2019 Photon Storm Ltd.
20055+
* @license {@link https://opensource.org/licenses/MIT|MIT License}
20056+
*/
20057+
20058+
/**
20059+
* The Complete Event.
20060+
*
20061+
* @event SpinePluginEvents#EVENT
20062+
* @since 3.19.0
20063+
*/
20064+
module.exports = 'event';
20065+
20066+
20067+
/***/ }),
20068+
20069+
/***/ "./events/INTERRUPTED_EVENT.js":
20070+
/*!*************************************!*\
20071+
!*** ./events/INTERRUPTED_EVENT.js ***!
20072+
\*************************************/
20073+
/*! no static exports found */
20074+
/***/ (function(module, exports) {
20075+
20076+
/**
20077+
* @author Richard Davey <rich@photonstorm.com>
20078+
* @copyright 2019 Photon Storm Ltd.
20079+
* @license {@link https://opensource.org/licenses/MIT|MIT License}
20080+
*/
20081+
20082+
/**
20083+
* The Complete Event.
20084+
*
20085+
* @event SpinePluginEvents#INTERRUPTED
20086+
* @since 3.19.0
20087+
*/
20088+
module.exports = 'interrupted';
20089+
20090+
20091+
/***/ }),
20092+
20093+
/***/ "./events/START_EVENT.js":
20094+
/*!*******************************!*\
20095+
!*** ./events/START_EVENT.js ***!
20096+
\*******************************/
20097+
/*! no static exports found */
20098+
/***/ (function(module, exports) {
20099+
20100+
/**
20101+
* @author Richard Davey <rich@photonstorm.com>
20102+
* @copyright 2019 Photon Storm Ltd.
20103+
* @license {@link https://opensource.org/licenses/MIT|MIT License}
20104+
*/
20105+
20106+
/**
20107+
* The Complete Event.
20108+
*
20109+
* @event SpinePluginEvents#START
20110+
* @since 3.19.0
20111+
*/
20112+
module.exports = 'start';
20113+
20114+
20115+
/***/ }),
20116+
20117+
/***/ "./events/index.js":
20118+
/*!*************************!*\
20119+
!*** ./events/index.js ***!
20120+
\*************************/
20121+
/*! no static exports found */
20122+
/***/ (function(module, exports, __webpack_require__) {
20123+
20124+
/**
20125+
* @author Richard Davey <rich@photonstorm.com>
20126+
* @copyright 2019 Photon Storm Ltd.
20127+
* @license {@link https://opensource.org/licenses/MIT|MIT License}
20128+
*/
20129+
20130+
/**
20131+
* @namespace SpinePluginEvents
20132+
*/
20133+
20134+
module.exports = {
20135+
20136+
COMPLETE: __webpack_require__(/*! ./COMPLETE_EVENT */ "./events/COMPLETE_EVENT.js"),
20137+
DISPOSE: __webpack_require__(/*! ./DISPOSE_EVENT */ "./events/DISPOSE_EVENT.js"),
20138+
END: __webpack_require__(/*! ./END_EVENT */ "./events/END_EVENT.js"),
20139+
EVENT: __webpack_require__(/*! ./EVENT_EVENT */ "./events/EVENT_EVENT.js"),
20140+
INTERRUPTED: __webpack_require__(/*! ./INTERRUPTED_EVENT */ "./events/INTERRUPTED_EVENT.js"),
20141+
START: __webpack_require__(/*! ./START_EVENT */ "./events/START_EVENT.js")
20142+
20143+
};
20144+
20145+
1997120146
/***/ }),
1997220147

1997320148
/***/ "./gameobject/SpineGameObject.js":
@@ -19991,6 +20166,7 @@ var ComponentsFlip = __webpack_require__(/*! ../../../../src/gameobjects/compone
1999120166
var ComponentsScrollFactor = __webpack_require__(/*! ../../../../src/gameobjects/components/ScrollFactor */ "../../../src/gameobjects/components/ScrollFactor.js");
1999220167
var ComponentsTransform = __webpack_require__(/*! ../../../../src/gameobjects/components/Transform */ "../../../src/gameobjects/components/Transform.js");
1999320168
var ComponentsVisible = __webpack_require__(/*! ../../../../src/gameobjects/components/Visible */ "../../../src/gameobjects/components/Visible.js");
20169+
var SpineEvents = __webpack_require__(/*! ../events/ */ "./events/index.js");
1999420170
var GameObject = __webpack_require__(/*! ../../../../src/gameobjects/GameObject */ "../../../src/gameobjects/GameObject.js");
1999520171
var SpineGameObjectRender = __webpack_require__(/*! ./SpineGameObjectRender */ "./gameobject/SpineGameObjectRender.js");
1999620172
var AngleBetween = __webpack_require__(/*! ../../../../src/math/angle/Between */ "../../../src/math/angle/Between.js");
@@ -20312,12 +20488,12 @@ var SpineGameObject = new Class({
2031220488
this.stateData = data.stateData;
2031320489

2031420490
this.state.addListener({
20315-
event: function (entry, event) { console.log('event fired ' + event.data + ' at track' + entry.trackIndex); },
20316-
complete: function (entry) { console.log('track ' + entry.trackIndex + ' completed'); },
20317-
start: function (entry) { console.log('animation is set at ' + entry.trackIndex); },
20318-
end: function (entry) { console.log('animation was ended at ' + entry.trackIndex); },
20319-
dispose: function (entry) { console.log('animation was disposed at ' + entry.trackIndex); },
20320-
interrupted: function (entry) { console.log('animation was interrupted at ' + entry.trackIndex); }
20491+
event: this.onEvent.bind(this),
20492+
complete: this.onComplete.bind(this),
20493+
start: this.onStart.bind(this),
20494+
end: this.onEnd.bind(this),
20495+
dispose: this.onDispose.bind(this),
20496+
interrupted: this.onInterrupted.bind(this)
2032120497
});
2032220498

2032320499
if (animationName)
@@ -20340,6 +20516,36 @@ var SpineGameObject = new Class({
2034020516
return this.updateSize();
2034120517
},
2034220518

20519+
onComplete: function (entry)
20520+
{
20521+
this.emit(SpineEvents.COMPLETE, entry);
20522+
},
20523+
20524+
onDispose: function (entry)
20525+
{
20526+
this.emit(SpineEvents.DISPOSE, entry);
20527+
},
20528+
20529+
onEnd: function (entry)
20530+
{
20531+
this.emit(SpineEvents.END, entry);
20532+
},
20533+
20534+
onEvent: function (entry, event)
20535+
{
20536+
this.emit(SpineEvents.EVENT, entry, event);
20537+
},
20538+
20539+
onInterrupted: function (entry)
20540+
{
20541+
this.emit(SpineEvents.INTERRUPTED, entry);
20542+
},
20543+
20544+
onStart: function (entry)
20545+
{
20546+
this.emit(SpineEvents.START, entry);
20547+
},
20548+
2034320549
refresh: function ()
2034420550
{
2034520551
if (this.root)
@@ -20570,11 +20776,11 @@ var SpineGameObject = new Class({
2057020776
if (loop === undefined) { loop = false; }
2057120777
if (ignoreIfPlaying === undefined) { ignoreIfPlaying = false; }
2057220778

20573-
if (ignoreIfPlaying)
20779+
if (ignoreIfPlaying && this.state)
2057420780
{
20575-
var current = this.getCurrentAnimation(trackIndex);
20781+
var currentTrack = this.state.getCurrent(0);
2057620782

20577-
if (current && current.name === animationName)
20783+
if (currentTrack && currentTrack.animation.name === animationName && !currentTrack.isComplete())
2057820784
{
2057920785
return this;
2058020786
}

plugins/spine/dist/SpinePlugin.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @author Richard Davey <rich@photonstorm.com>
3+
* @copyright 2019 Photon Storm Ltd.
4+
* @license {@link https://opensource.org/licenses/MIT|MIT License}
5+
*/
6+
7+
/**
8+
* The Complete Event.
9+
*
10+
* @event SpinePluginEvents#COMPLETE
11+
* @since 3.19.0
12+
*/
13+
module.exports = 'complete';
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @author Richard Davey <rich@photonstorm.com>
3+
* @copyright 2019 Photon Storm Ltd.
4+
* @license {@link https://opensource.org/licenses/MIT|MIT License}
5+
*/
6+
7+
/**
8+
* The Complete Event.
9+
*
10+
* @event SpinePluginEvents#DISPOSE
11+
* @since 3.19.0
12+
*/
13+
module.exports = 'dispose';
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @author Richard Davey <rich@photonstorm.com>
3+
* @copyright 2019 Photon Storm Ltd.
4+
* @license {@link https://opensource.org/licenses/MIT|MIT License}
5+
*/
6+
7+
/**
8+
* The Complete Event.
9+
*
10+
* @event SpinePluginEvents#END
11+
* @since 3.19.0
12+
*/
13+
module.exports = 'end';
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @author Richard Davey <rich@photonstorm.com>
3+
* @copyright 2019 Photon Storm Ltd.
4+
* @license {@link https://opensource.org/licenses/MIT|MIT License}
5+
*/
6+
7+
/**
8+
* The Complete Event.
9+
*
10+
* @event SpinePluginEvents#EVENT
11+
* @since 3.19.0
12+
*/
13+
module.exports = 'event';
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @author Richard Davey <rich@photonstorm.com>
3+
* @copyright 2019 Photon Storm Ltd.
4+
* @license {@link https://opensource.org/licenses/MIT|MIT License}
5+
*/
6+
7+
/**
8+
* The Complete Event.
9+
*
10+
* @event SpinePluginEvents#INTERRUPTED
11+
* @since 3.19.0
12+
*/
13+
module.exports = 'interrupted';
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @author Richard Davey <rich@photonstorm.com>
3+
* @copyright 2019 Photon Storm Ltd.
4+
* @license {@link https://opensource.org/licenses/MIT|MIT License}
5+
*/
6+
7+
/**
8+
* The Complete Event.
9+
*
10+
* @event SpinePluginEvents#START
11+
* @since 3.19.0
12+
*/
13+
module.exports = 'start';

plugins/spine/src/events/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* @author Richard Davey <rich@photonstorm.com>
3+
* @copyright 2019 Photon Storm Ltd.
4+
* @license {@link https://opensource.org/licenses/MIT|MIT License}
5+
*/
6+
7+
/**
8+
* @namespace SpinePluginEvents
9+
*/
10+
11+
module.exports = {
12+
13+
COMPLETE: require('./COMPLETE_EVENT'),
14+
DISPOSE: require('./DISPOSE_EVENT'),
15+
END: require('./END_EVENT'),
16+
EVENT: require('./EVENT_EVENT'),
17+
INTERRUPTED: require('./INTERRUPTED_EVENT'),
18+
START: require('./START_EVENT')
19+
20+
};

0 commit comments

Comments
 (0)