Exemplo n.º 1
0
//写邮件界面对象
void MailWritePopUpView::onEnter() {
    PopupBaseView::onEnter();
    UIComponent::getInstance()->showPopupView(1);
    UIComponent::getInstance()->hideReturnBtn();
    CCSafeNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(MailWritePopUpView::onCloseEvent), MAIL_SEND_SUCCESS, NULL);
    CCSafeNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(MailWritePopUpView::onUpdateStatusEvent), MSG_INPUT_TEXT_EVENT, NULL);

    CCSafeNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(MailWritePopUpView::onUpdateStatusEvent), MSG_MAIL_GIFT_CHOOSE, NULL);
    CCSafeNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(MailWritePopUpView::onSendGiftBack), MAIL_SEND_GIFT_SUCCESS, NULL);
    CCSafeNotificationCenter::sharedNotificationCenter()->addObserver(this, CC_CALLFUNCO_SELECTOR(MailWritePopUpView::onSendGiftBack), MSG_SEND_HEART_COMMAND_SUC, nullptr);
    CCSafeNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(MailWritePopUpView::onRefreshName), CHAT_ROOM_NAME_REFRESH, NULL);
    CCSafeNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(MailWritePopUpView::onChoosePlayer), MSG_USER_CHOOSE, NULL);
    CCSafeNotificationCenter::sharedNotificationCenter()->addObserver(this, CC_CALLFUNCO_SELECTOR(MailWritePopUpView::onChoosePlayer), MSG_IVITE_VIEW_CHOOSE_TO_PLAYER, nullptr);
//    setTitleName(_lang("105513"));
    m_titleText->setString(_lang("105513"));
    if (m_isSendHeartMail)
    {
        m_titleText->setString(_lang("150535"));
    }
    if(mInited==true) {
        m_nameEditBox->addTargetedDelegate();
        m_contentEditBox->addTargetedDelegate();
    }
    setTouchEnabled(true);
    mInited=true;
    MailController::getInstance()->getAllianceMember();
}
Exemplo n.º 2
0
NotificationCenterTest::NotificationCenterTest()
: _showImage(false)
{
    auto s = Director::getInstance()->getWinSize();

    auto pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(NotificationCenterTest::toExtensionsMainLayer, this));
    pBackItem->setPosition(Vec2(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
    auto pBackMenu = Menu::create(pBackItem, nullptr);
    pBackMenu->setPosition( Vec2::ZERO );
    addChild(pBackMenu);

    auto label1 = Label::createWithTTF("switch off", "fonts/Marker Felt.ttf", 26);
    auto label2 = Label::createWithTTF("switch on", "fonts/Marker Felt.ttf", 26);
    auto item1 = MenuItemLabel::create(label1);
    auto item2 = MenuItemLabel::create(label2);
    auto item = MenuItemToggle::createWithCallback( CC_CALLBACK_1(NotificationCenterTest::toggleSwitch, this), item1, item2, nullptr);
    // turn on
    item->setSelectedIndex(1);
    auto menu = Menu::create(item, nullptr);
    menu->setPosition(Vec2(s.width/2+100, s.height/2));
    addChild(menu);

    auto menuConnect = Menu::create();
    menuConnect->setPosition(Vec2::ZERO);
    addChild(menuConnect);

    for (int i = 1; i <= 3; i++)
    {
        Light* light = Light::lightWithFile("Images/Pea.png");
        light->setTag(kTagLight+i);
        light->setPosition(Vec2(100, s.height/4*i));
        addChild(light);

        auto label1 = Label::createWithTTF("not connected", "fonts/Marker Felt.ttf", 26);
        auto label2 = Label::createWithTTF("connected", "fonts/Marker Felt.ttf", 26);
        auto item1 = MenuItemLabel::create(label1);
        auto item2 = MenuItemLabel::create(label2);
        auto item = MenuItemToggle::createWithCallback( CC_CALLBACK_1(NotificationCenterTest::connectToSwitch, this), item1, item2, nullptr);
        item->setTag(kTagConnect+i);
        item->setPosition(Vec2(light->getPosition().x, light->getPosition().y+50));
        menuConnect->addChild(item, 0);
        if (i == 2)
        {
            item->setSelectedIndex(1);
        }
        bool bConnected = item->getSelectedIndex() == 1 ? true : false;
        light->setIsConnectToSwitch(bConnected);
    }

    NotificationCenter::getInstance()->postNotification(MSG_SWITCH_STATE, (Ref*)(intptr_t)item->getSelectedIndex());

    /* for testing removeAllObservers */
    NotificationCenter::getInstance()->addObserver(this, CC_CALLFUNCO_SELECTOR(NotificationCenterTest::doNothing), "random-observer1", nullptr);
    NotificationCenter::getInstance()->addObserver(this, CC_CALLFUNCO_SELECTOR(NotificationCenterTest::doNothing), "random-observer2", nullptr);
    NotificationCenter::getInstance()->addObserver(this, CC_CALLFUNCO_SELECTOR(NotificationCenterTest::doNothing), "random-observer3", nullptr);
}
Exemplo n.º 3
0
void Star::onEnter()
{
	WJLayerJson2x::onEnter();

	NotificationCenter::getInstance()->addObserver(this, CC_CALLFUNCO_SELECTOR(Star::starChangedNotification),
		"heartChanged", NULL);
}
Exemplo n.º 4
0
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();
}
Exemplo n.º 5
0
TargetLayer::TargetLayer()
{
	NotificationCenter::getInstance()->addObserver(this, CC_CALLFUNCO_SELECTOR(TargetLayer::roundChanged), MSG_ROUND_CHANGED, nullptr);
}