SFML community forums
Help => General => Topic started by: Gobbles on May 19, 2014, 11:05:36 pm
-
Hey guys, just wondering if anyone has worked with spine for sfml at all? If so I am wondering if you have set up callback functions at a class level? I've been going at it for a few days now and I can't seem to make much progress on it. My brain is fried.
Here is a thread I opened there: http://esotericsoftware.com/forum/viewtopic.php?f=7&t=2657&p=13016#p13016
Nate responds, which is awesome, but I'm not sure if I'm just gone complete braindead on it or not but ignore my 2nd post in it because I completely jumped the gun (I thought Lambdas were the solution, but apparently not).
If anyone has any nuggets of wisdom or anything I'd certainly appreciate it.
-
If the question is "how do I get a pointer to a member function", I believe the syntax is &class::method. I've never had to do that but I've seen examples of it on pages like http://www.cplusplus.com/reference/functional/mem_fun/.
-
Yeah I've tried this, quickly plugging it in I get:
a value of type "void (MyClass::*)(AnimationState *state, int trackIndex, EventType type, Event *event, int loopCount)" cannot be assigned to an entity of type "spAnimationStateListener"
this is spAnimationStateListener: typedef void (*spAnimationStateListener) (spAnimationState* state, int trackIndex, spEventType type, spEvent* event, int loopCount);
-
Don't use std::mem_fun with the "u" and consorts, they have been deprecated. C++11 has introduced new functionals, everything is listed here (http://en.cppreference.com/w/cpp/utility/functional). The most important additions are std::function, std::bind and std::mem_fn.
Note: C++11 function objects are not convertible to function pointers. I don't know why Spine resorts to function pointers, is it written in C or C++98?
-
Almost all is written in C, but there is at least 1 c++ class which is used for sfml, spine-sfml.h.
Here's the source with an example: https://github.com/EsotericSoftware/spine-runtimes/tree/master/spine-sfml
-
I got it figured out. Turns out they updated the C source a few weeks back with the void* rendererObject. Tossing your object instance into that and casting it into an instance inside the callback allows for everything I need.