Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Spine for SFML  (Read 3808 times)

0 Members and 1 Guest are viewing this topic.

Gobbles

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Email
Spine for SFML
« 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.

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Spine for SFML
« Reply #1 on: May 19, 2014, 11:19:01 pm »
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/.

Gobbles

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Email
Re: Spine for SFML
« Reply #2 on: May 19, 2014, 11:26:28 pm »
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);

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Spine for SFML
« Reply #3 on: May 19, 2014, 11:28:15 pm »
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. 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?
« Last Edit: May 19, 2014, 11:31:50 pm by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Gobbles

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Email
Re: Spine for SFML
« Reply #4 on: May 19, 2014, 11:46:03 pm »
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

Gobbles

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Email
Re: Spine for SFML
« Reply #5 on: May 21, 2014, 04:25:43 am »
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.