Callback from C++ to Script
by Gary Myers · in Torque 2D Beginner · 02/17/2014 (8:16 pm) · 2 replies
I am creating an extension to the T2D engine in C++ (actually ObjC) and I can't seem to figure out how implement a callback to a script. Basically, I have a global function (e.g. not in a class exposed to TorqueScript) that wraps some native iOS code. I want to callback to the scripting side when the callback completes so I can take some other actions.
I was using GameCenterManager as a point of reference since it is not a SimObject subclass. However, I see that it does things like the following which I think would let a script listen for it:
However, I don't see an example in script of receiving a gamecenter callback. Based on my experiments it seems to be just a global (non-class) function I define like:
Is this the right approach?
Thanks!
I was using GameCenterManager as a point of reference since it is not a SimObject subclass. However, I see that it does things like the following which I think would let a script listen for it:
Con::executef(2, "callbackFromMyCode", "0");
However, I don't see an example in script of receiving a gamecenter callback. Based on my experiments it seems to be just a global (non-class) function I define like:
function callbackFromMyCode(%val)
Is this the right approach?
Thanks!
About the author
Employee Michael Perry
ZombieShortbus