Hello,
In the UI code, it seems we still are using an old way of triggering events/doing a callback :
exemple :
typedef enum { CHECKBOX_STATE_EVENT_SELECTED, CHECKBOX_STATE_EVENT_UNSELECTED }CheckBoxEventType; typedef void (Ref::*SEL_SelectedStateEvent)(Ref*,CheckBoxEventType); #define checkboxselectedeventselector(_SELECTOR) (SEL_SelectedStateEvent)(&_SELECTOR) void addEventListenerCheckBox(Ref* target,SEL_SelectedStateEvent selector);
With this design, it forces the user to have a callback as a Ref*, which means inherit of some other cocos2d-x object.
It seems to me that this is uneccessary. The callback could just be any function, since we are using C++11 :
void addEventListenerCheckBox(std::function<void(Ref*,CheckBoxEventType)>());
This is clearer, more explicit and standard than some extra type defined hidden in cocos2d-x code.
Also it allows the user to plug any function to it, especially lambda functions that are very handy to keep UI code small.
So is there any specific reason why it is not this way already ?
Thanks for any input on this, I m currently wondering how to change my code to handle these events…