void Light::setIsConnectToSwitch(bool bConnectToSwitch) { _connected = bConnectToSwitch; if (_connected) { NotificationCenter::getInstance()->addObserver(this, callfuncO_selector(Light::switchStateChanged), MSG_SWITCH_STATE, NULL); } else { NotificationCenter::getInstance()->removeObserver(this, MSG_SWITCH_STATE); } updateLightState(); }
void Light::setIsConnectToSwitch(bool bConnectToSwitch) { _connected = bConnectToSwitch; if (_connected) { NotificationCenter::getInstance()->addObserver(this, CC_CALLFUNCO_SELECTOR(Light::switchStateChanged), MSG_SWITCH_STATE, nullptr); } else { NotificationCenter::getInstance()->removeObserver(this, MSG_SWITCH_STATE); } updateLightState(); }
void Light::switchStateChanged(Ref* obj) { s_bSwitchOn = obj == 0x00 ? false : true; updateLightState(); }
void Light::switchStateChanged(CCObject* obj) { int index = (int)obj; s_bSwitchOn = index == 0 ? false : true; updateLightState(); }