Example #1
0
void GeneralGroupLogic::onEnter()
{
    CCNode::onEnter();

    // Create general buttons in game.
    for (UINT i = 0; i < m_generalData.size(); ++i)
    {
        UIButton* pButton = UIButton::create();
        pButton->setWidgetTag(static_cast<int>(i));
        pButton->setPosition(ccp(VisibleRect::right().x - 10, 30 * (1 + i) + 50));
        pButton->setTouchEnable(true);
        // Set relationship between these picture with generalType.
        EGeneralType type = m_generalData[i];
        pButton->setTextures(NormalPng[type], SelectedPng[type], DisablePng[type]);

        pButton->addReleaseEvent(this, coco_releaseselector(GeneralGroupLogic::GeneralBottonClicked));
        pButton->addPushDownEvent(this, coco_releaseselector(GeneralGroupLogic::GeneralBottonPushDown));

        pButton->setScale(0.5f);

        UiManager::Singleton().AddChildWidget(pButton);
    }
}
void LoginScene::onEnter(){
    CCLayer::onEnter();
	TouchGroup* ui = TouchGroup::create();
	loginWidget = GUIReader::shareReader()->widgetFromJsonFile("Scene/LoginSence/LoginSence.json");
    loginWidget->setSizeType(SIZE_ABSOLUTE);
    loginWidget->setSize(CCDirector::sharedDirector()->getVisibleSize());
    
    ui->addWidget(loginWidget);
	ui->setAnchorPoint(CCPointZero);
	this->addChild(ui);
    
    
    //登陆区域
    UIPanel* login_panel = (UIPanel*)UIHelper::seekWidgetByName(loginWidget, "bodyPanel");
    login_panel->setCloseIME(true);

    //loginWidget->getChildByTag(4);
    //UIPanel* bg_panel = (UIPanel*)loginWidget->getChildByTag(63);

    UIImageView *upImg = (UIImageView*)UIHelper::seekWidgetByName(loginWidget, "upImg");
    CCSize fs = CCDirector::sharedDirector()->getVisibleSize();
    //float scale = fs.width/upImg->getSize().width;

    float scale = std::max(fs.width/upImg->getSize().width, fs.height/upImg->getSize().height);
    //if(scale > 1){
        upImg->setScale(scale);
    //}

    UIImageView *logo = (UIImageView*)UIHelper::seekWidgetByName(loginWidget, "logoImage");

    float sca = std::min(fs.width/640, fs.height/960);
    logo->setScale(sca);

    ImageView *userIcon = (ImageView *)UIHelper::seekWidgetByName(loginWidget, "userIcon");
    userIcon->setScale(sca);

    ImageView *userIconBg = (ImageView *)UIHelper::seekWidgetByName(loginWidget, "userIconBg");
    userIconBg->setScale(sca);    

    ImageView *userLi = (ImageView*)UIHelper::seekWidgetByName(loginWidget, "usernameLiImage");
    TextField *usernameInput = (TextField*)UIHelper::seekWidgetByName(loginWidget, "username");
    //userLi->setScale(sca);
    usernameInput->setScale(sca);

    ImageView *passwordLi = (ImageView*)UIHelper::seekWidgetByName(loginWidget, "passwordLiImage");
    //passwordLi->setScale(sca);
    
    TextField *passwordInput = (TextField*)UIHelper::seekWidgetByName(loginWidget, "password");
    passwordInput->setScale(sca);


    UIButton* loginBtn = (UIButton*)UIHelper::seekWidgetByName(loginWidget, "loginButton");
    //login_panel->getChildByTag(8);
    loginBtn->addTouchEventListener(this,toucheventselector(LoginScene::loginPress));
    

    //float ms = std::min(fs.width/640, fs.height/960);
    //if (ms < 1)
   // {
        //logo->setScale(ms);
    loginBtn->setScale(sca);
    //}
    Button *regB = (Button*)UIHelper::seekWidgetByName(loginWidget, "regButton");
    regB->setScale(sca);


    UIButton* topBtn = (UIButton*)UIHelper::seekWidgetByName(loginWidget, "tabLoginButton");
    topBtn->setScale(sca);

    CCLog("init UIPanel");


    //用户名
    /*
    m_userName = CCEditBox::create(CCSize(320,50), CCScale9Sprite::createWithSpriteFrameName("button.png"));
	m_userName->setFontSize(23);
	m_userName->setAnchorPoint(CCPointZero);
	m_userName->setPlaceHolder("请输入用户名");
    m_userName->setPlaceholderFontColor(ccc3(248,252,255));
	m_userName->setInputMode(kEditBoxInputModeAny);
	m_userName->setReturnType(kKeyboardReturnTypeDone);
	m_userName->setPosition(ccp(153,378));
	m_userName->setDelegate(this);
	m_userName->setTouchPriority(0);
    */

    username = (UITextField*)UIHelper::seekWidgetByName(loginWidget, "username");

    password = (UITextField*)UIHelper::seekWidgetByName(loginWidget, "password");
    midView = (UIPanel*)UIHelper::seekWidgetByName(loginWidget, "midView");

    CCLog("init midView");


    //密码
  
    
    
    UIButton* registerBtn = (UIButton*)UIHelper::seekWidgetByName(loginWidget, "regButton");
    //login_panel->getChildByTag(44);
    registerBtn->addTouchEventListener(this, toucheventselector(LoginScene::registerPress));
    
    //切换账号
    UIButton* tabLoginBtn = (UIButton*)UIHelper::seekWidgetByName(loginWidget, "tabLoginButton");//login_panel->getChildByTag(87);
    tabLoginBtn->addTouchEventListener(this, toucheventselector(LoginScene::tabloginPress));
    
    //login_panel->addNode(m_userName);
    //login_panel->addNode(m_passWord);
    CCLog("init button");
    //更新显示
    refurbishScene();

    
}