我有一个工作线程在后台进行计算,我想发送一个事件/消息来调用更新函数来在工作线程完成计算后更新屏幕上的图形。cocos2d来自不同线程的通知/事件/消息
如何在cocos2d中做到这一点?
一些演示代码:
-(void) updateGraphic
{
//this one update all the graphics/sprite
}
//note workerThreadFunc is being used to start a new thread
-(void) workerThreadFunc
{
//...
//...
//finish calculation here
//since it's in a different thread, I cannot call updateGraphic directly here
//So I need a event to notify update Graphic here somehow
}
我的感觉是,即使在基本工作之前,您也正朝着线程化实现方向发展。首先实现你的应用程序可能是值得的,然后再考虑是否值得做多线程编程。尤其是因为迄今为止唯一具有多个硬件线程的iOS设备是iPad 2和iPhone 4S。 – LearnCocos2D