Exemplo n.º 1
0
void PlayScene::onBtnClothes(CCObject *target, TouchEventType e) {
  UIButton* btn = (UIButton *)ui_layer_->getWidgetByName(btn_name[sub_stage_id_]);
  if (btn) {
    if(e == TOUCH_EVENT_BEGAN) {
      btn_start_pos_ = btn->getPosition();
    } else if(e == TOUCH_EVENT_ENDED) {
      CCPoint pos = btn->getPosition();
      if(btn_start_pos_.fuzzyEquals(pos, 100.0f)) {
        btn->setPosition(btn_start_pos_);
      } else {
        if(!all_finish_) {
          btn->setEnabled(false);
          btn = (UIButton *)ui_layer_->getWidgetByName("BtnStartPlay");
          btn->setEnabled(true); 
        } else {
          btn->setEnabled(false);
          User::CurrentUser()->set_stageid(stageid_ + 1);
          User::CurrentUser()->Flush();
          PopWin::Instance().ShowPopScene(this, true, toucheventselector(PlayScene::onPopBack));
        }
      }
    }
  }
  CCLOG("%s\n", __FUNCTION__);
}
Exemplo n.º 2
0
void FrontCoverLayer::setLastLoginSever()
{
	if(m_layout)
	{
		UIButton* button = m_layout->FindChildObjectByName<UIButton>("latestSeverBt");
		if(button)
		{
			const char* ip = UserData::GetLastIP();
			unsigned int port = UserData::GetLastPort();
			const char* name = UserData::GetLastServerName();
			if(*ip == '\0' || port == 0)
			{
				button->setEnabled(false);
			}
			else
			{
				UILabelTTF* label = button->getTextLabel();
				if(label)
				{
					label->setString(name);
				}
			}
		}
	}
}
Exemplo n.º 3
0
void PlayScene::onBtnStartPlay(CCObject *target, TouchEventType e) {
  if (e != TOUCH_EVENT_ENDED)
    return;
  PLAY_BTNSOUND;
  if (GotoStartSceneIfError())
  	return;
  UIButton* btn = (UIButton *)ui_layer_->getWidgetByName("BtnStartPlay");
  if (btn) {
    btn->setEnabled(false);
  }
  CCLOG("%s\n", __FUNCTION__);
  card_mgr_.StartSubStage();
}
Exemplo n.º 4
0
void LoginScene::refurbishScene(){
    //本地有存储用户名
    string loginNmaeKey = CCUserDefault::sharedUserDefault()->getStringForKey("loginName");
    
    int avatarKey = CCUserDefault::sharedUserDefault()->getIntegerForKey("avatar");
    CCLog("avatarKey:%d", avatarKey);
    
    //UIPanel* login_panel = (UIPanel*)loginWidget->getChildByTag(4);
    UIPanel* login_panel = (UIPanel*)UIHelper::seekWidgetByName(loginWidget, "bodyPanel");

    UIImageView* userIcon = (UIImageView*)UIHelper::seekWidgetByName(loginWidget, "userIcon");
    //login_panel->getChildByName("userIcon");
    UIImageView* usernameLable = (UIImageView*)UIHelper::seekWidgetByName(loginWidget, "usernameLiImage");
    
    //login_panel->getChildByName("usernameLiImage");
    
    UIButton* tabLoginBtn = (UIButton*)UIHelper::seekWidgetByName(loginWidget, "tabLoginButton");
    //login_panel->getChildByTag(87);
    
    //输入框位置
    UIImageView* passwordLiImage = (UIImageView*)UIHelper::seekWidgetByName(loginWidget, "passwordLiImage");

    //login_panel->getChildByTag(57);
    UIImageView* usernameLiImage = (UIImageView*)UIHelper::seekWidgetByName(loginWidget, "usernameLiImage");

    //login_panel->getChildByTag(60);
    CCPoint usernamePoint = usernameLiImage->getPosition();
    
    //m_userName->setPosition(ccp(usernamePoint.x - 407/2 + 40, usernamePoint.y - 15));
    
    CCPoint upos = username->getPosition();

    //CCLog("");
    //username->setPosition(ccp(upos.x, usernamePoint.y - 15));


    CCPoint pwdPoint = passwordLiImage->getPosition();
    //m_passWord->setPosition(ccp(pwdPoint.x - 407/2 + 40, pwdPoint.y - 15));
    CCPoint ppos = password->getPosition();
    //password->setPosition(ccp(ppos.x, pwdPoint.y - 15));


    if(avatarKey > 0 && avatarKey <= 32){
        char avatarItem[50];
        sprintf(avatarItem, "flags/%d.png", avatarKey);
        userIcon->loadTexture(avatarItem);
    }

    
    //用户已经 登陆过了
    if (loginNmaeKey != "") {
        //隐藏用户输入框
        //m_userName->setText(loginNmaeKey.c_str());
        username->setText(loginNmaeKey.c_str());
        username->setEnabled(false);

        //m_userName->setVisible(false);
        
        usernameLable->setVisible(false);
        
        UILabel* iconNameLabel = (UILabel*)UIHelper::seekWidgetByName(loginWidget, "usernameLabel");
        //userIcon->getChildByTag(47);
        iconNameLabel->setText(loginNmaeKey.c_str());
        
        tabLoginBtn->setEnabled(true);
    }else{
        //m_userName->setVisible(true);
        username->setEnabled(true);

        usernameLable->setVisible(true);
        userIcon->setVisible(false);
        
        tabLoginBtn->setEnabled(false);
    }
}