Hi all (again),
I’ve been busy translating the Roaming Ralph tutorial to C++. It’s almost done – Just the animation part.
But, I’m having some trouble with the keypresses too. Usually, it works fine:
void exit_event(const Event * theEvent, void * data) {
exit(0);
}
//...
World::World(WindowFramework *window) {
//...
framework_ptr=window->get_panda_framework();
//...
framework_ptr->define_key("escape", "Quit", exit_event, 0);
//...
}
Though, once I want an event to a function within my class World, It won’t work anymore:
World::World(WindowFramework *window) {
//...
pair<string, bool> data=("left", true);
framework_ptr->define_key("arrow_left", "Rotate Ralph Left", set_key, (void *) &data);
//...
}
World::set_key(const Event * theEvent, void * data) {
//...
}
That throws an error because there is no overloaded function for define_key. If I make set_key a global function instead of a subfunction of the class World it works.
Does anybody have an idea how to correct this? Thanks in advance.