Posting code as an image makes it more difficult to help you, especially with Chinese comments that aren't easy to translate from an image.
I don't think we provide a Lua API for cocos2dx? You may want to look in the source code and see what methods are available, make sure setEventListener
is mapped in Lua. Also, cocos2dx is notorious for taking our runtime, modifying it, and distributing it in cocos2dx. You may want to replace our runtime in cocos2dx with the official 3.8 runtime.
The C++ counterpart has a setEventListener
method:
EsotericSoftware/spine-runtimesblob/3.8/spine-cocos2dx/src/spine/SkeletonAnimation.h#L92
setEventListener
takes an EventListener
function pointer:
EsotericSoftware/spine-runtimesblob/3.8/spine-cocos2dx/src/spine/SkeletonAnimation.h#L46
The function parameters are TrackEntry
and Event
. Your function only takes an event. Who knows what Lua will do in that scenario. Maybe it crashes or maybe it passes only the TrackEntry
, in which case trackEntry.data.name
will fail.