根据这个邮件列表线程,可以使用IoObject_rawDoString_label_()
和IoState_retain_()
编译来自源的消息并将其应用到IoMessage_locals_performOn_()
.
IoMessage_newWithName_()
或者,可以通过和函数手动构造消息IoMessage_setCachedArg_*()
。
我没有找到任何文档,但是可以在IoMessage.h中找到相关函数的列表。
适用于这种特殊情况的代码是
/* When you initialize everything */
renderMessage = IoObject_rawDoString_label_(IoState_lobby(state),
IoState_symbolWithCString_(state, "message(Game render())"),
IoState_symbolWithCString_(state, "[Game render]"));
IoState_retain_(state, renderMessage);
/* In the game loop's render function */
IoMessage_locals_performOn_(renderMessage, IoState_lobby(state), IoState_lobby(state));
对于您需要传递参数的消息,您需要这个:
/* When you initialize everything */
updateMessage = IoMessage_newWithName_(state, IoState_symbolWithCString_(state, "update"));
IoState_retain_(state, updateMessage);
/* In the game loop's update function */
IoMessage_setCachedArg_toInt_(updateMessage, 0, deltaTime);
IoMessage_locals_performOn_(updateMessage, IoState_lobby(state),
IoObject_getSlot_(IoState_lobby(state), IoState_symbolWithCString_(state, "Game")));