Subscribe/Unsubscribe to Callbacks
by James Ford · in Torque Game Builder · 09/21/2008 (6:08 pm) · 0 replies
I'd love to see the ability to dynamically subscribe/unsubscribe to a callback. And I don't just mean a particular t2dSceneObject saying "I don't care about onPositionTarget anymore", I mean any number of script functions or script-object-methods could be subscribed to a callback at the same time.
Although you can currently call whatever you want from inside a callback, including other object methods or functions, there isn't a really great way to change those dynamically. You could perhaps store the object id, method name, or function name in a dynamic field and do an eval in the callback.
But it seems like this would be such a useful feature, and add so much more power to callbacks, that it would be worth integrating this as a feature of t2dSceneObject's.
By the way, I have a somewhat hacky way of doing this using the EventManager if anyone is interested.
Although you can currently call whatever you want from inside a callback, including other object methods or functions, there isn't a really great way to change those dynamically. You could perhaps store the object id, method name, or function name in a dynamic field and do an eval in the callback.
But it seems like this would be such a useful feature, and add so much more power to callbacks, that it would be worth integrating this as a feature of t2dSceneObject's.
By the way, I have a somewhat hacky way of doing this using the EventManager if anyone is interested.
About the author
http://jamesdev.info