lua的观察者实现

CCNotificationCenter:sharedNotificationCenter():registerScriptObserver(nil, function(_, enemy) self:clickEnemy(enemy) end, "CLICK_ENEMY")

CCNotificationCenter:sharedNotificationCenter():unregisterScriptObserver(nil, "CLICK_ENEMY")

发送消息:

CCNotificationCenter:sharedNotificationCenter():postNotification("CLICK_ENEMY", self)

你可能感兴趣的:(lua)