Browse Source

[cpp] Closes #1404, add define SPINE_USE_STD_FUNCTION. When set, the animation state callback can be a std::function.

badlogic 6 years ago
parent
commit
f020c2ceba
1 changed files with 10 additions and 2 deletions
  1. 10 2
      spine-cpp/spine-cpp/include/spine/AnimationState.h

+ 10 - 2
spine-cpp/spine-cpp/include/spine/AnimationState.h

@@ -37,6 +37,10 @@
 #include <spine/SpineString.h>
 #include <spine/HasRendererObject.h>
 
+#ifdef SPINE_USE_STD_FUNCTION
+#include <functional>
+#endif
+
 namespace spine {
     enum EventType {
         EventType_Start,
@@ -55,9 +59,13 @@ namespace spine {
     class AnimationStateData;
     class Skeleton;
     class RotateTimeline;
-    
-    typedef void (*AnimationStateListener) (AnimationState* state, EventType type, TrackEntry* entry, Event* event);
 
+#ifdef SPINE_USE_STD_FUNCTION
+	typedef std::function<void (AnimationState* state, EventType type, TrackEntry* entry, Event* event)> AnimationStateListener;
+#else
+	typedef void (*AnimationStateListener) (AnimationState* state, EventType type, TrackEntry* entry, Event* event);
+#endif
+	
 	/// Abstract class to inherit from to create a callback object
 	class SP_API AnimationStateListenerObject {
 	public: