Example #1
0
void ButtonUtils::setButtonTitle(CCControlButton* button, const char *titleName)
{
    button->setTitleForState(CCStringMake(titleName), CCControlStateNormal);
    button->setTitleForState(CCStringMake(titleName), CCControlStateHighlighted);
    button->setTitleForState(CCStringMake(titleName), CCControlStateDisabled);
    button->setTitleForState(CCStringMake(titleName), CCControlStateSelected);
}
Example #2
0
void ConfigManager::LoadConfig(){
	string sqlstr="select * from config_save";
	{
		vector<map<string,string>> vdata;

		vdata = DBUtil::getDataInfo(sqlstr,NULL);
		int m_number = vdata.size();

		for(int i = 0;i<m_number;i++){


			ConfigStruct* cs = new ConfigStruct();
			cs->autorelease();
			cs->value = atof(((map<string,string>) vdata.at(i)).at("value").c_str());
			cs->dvalue = atof(((map<string,string>) vdata.at(i)).at("dvalue").c_str());


			cvs->setObject(cs,atof(((map<string,string>) vdata.at(i)).at("id").c_str()));

		}

		sqlstr = "select * from str_table";
	}
	{
		vector<map<string,string>> adata;

		adata = DBUtil::getDataInfo(sqlstr,NULL);
		int m_number = adata.size();

		for(int i = 0;i<m_number;i++){
			strtable->setObject(CCStringMake(((map<string,string>) adata.at(i)).at("content")),((map<string,string>) adata.at(i)).at("mask"));
		}
	}

}
Example #3
0
void JoyStickLayer::update(float t)
{

    if(INSTANCE(FightManager)->enoughAnger()){
        skillBtn->setEnabled(true);
        skillPro->setPercentage(100);
    }else{
        skillBtn->setEnabled(false);
        skillPro->setPercentage(INSTANCE(FightManager)->getAnger() * 100);
    }
    
    if(INSTANCE(GuideManager)->getIsGuiding()){
        GuideStep step = INSTANCE(GuideManager)->getCurrentStep();
        if(step == GuideStep_10007){
            skillBtn->setEnabled(true);
        }
        
        if(step == GuideStep_10003 || step == GuideStep_10004 ||step == GuideStep_10006 || step == GuideStep_10007 || step == GuideStep_10003){
            if(!attackBtn->isEnabled()){
                attackBtn->setEnabled(true);
            }
        }else{
            if(attackBtn->isEnabled()){
                attackBtn->setEnabled(false);
            }
        }
    }else{
        if(!attackBtn->isEnabled()){
            attackBtn->setEnabled(true);
        }
        
    }
    
    
    if(attackBtn->isHighlighted()) {
        CCNotificationCenter::sharedNotificationCenter()->postNotification(JoyStick_status,CCStringMake(JoyStick_attack));
        return;
    }
    
    if(skillBtn->isHighlighted()){
        CCNotificationCenter::sharedNotificationCenter()->postNotification(JoyStick_status,CCStringMake(JoyStick_skill));
        return;
    }
    
    
    CCPoint poi = ccpMult(joystick->getVelocity(), 50);
    
    if(poi.x == 0 && poi.y == 0){
        if(lastPoi.x !=0 || lastPoi.y != 0){
            CCNotificationCenter::sharedNotificationCenter()->postNotification(JoyStick_status,CCStringMake(JoyStick_none));
            lastPoi = poi;
        }
        return;
    }
    
    lastPoi = poi;
    
    float degree = atan2(poi.y, poi.x)*180/atan2(0.0, -1.0);
    
    if(degree <0){
        degree += 360;
    }
    if(degree >= 22.5 && degree < 67.5){
        //右上
        CCNotificationCenter::sharedNotificationCenter()->postNotification(JoyStick_status,CCStringMake(JoyStick_right_up));
    }else if(degree >= 67.5 && degree < 112.5){
        //上
        CCNotificationCenter::sharedNotificationCenter()->postNotification(JoyStick_status,CCStringMake(JoyStick_up));
    }else if(degree >= 112.5 && degree < 157.5){
        //左上
        CCNotificationCenter::sharedNotificationCenter()->postNotification(JoyStick_status,CCStringMake(JoyStick_left_up));
    }else if(degree >= 157.5 && degree < 202.5){
        //左
        CCNotificationCenter::sharedNotificationCenter()->postNotification(JoyStick_status,CCStringMake(JoyStick_left));
    }else if(degree >= 202.5 && degree < 247.5){
        //左下
        CCNotificationCenter::sharedNotificationCenter()->postNotification(JoyStick_status,CCStringMake(JoyStick_left_down));
    }else if(degree >= 247.5 && degree < 292.5){
        //下
        CCNotificationCenter::sharedNotificationCenter()->postNotification(JoyStick_status,CCStringMake(JoyStick_down));
    }else if(degree >= 292.5 && degree < 337.5){
        //右下
        CCNotificationCenter::sharedNotificationCenter()->postNotification(JoyStick_status,CCStringMake(JoyStick_right_down));
    }else{
        //右
        CCNotificationCenter::sharedNotificationCenter()->postNotification(JoyStick_status,CCStringMake(JoyStick_right));
    }
}
Example #4
0
void JoyStickLayer::attackHandler()
{
    CCNotificationCenter::sharedNotificationCenter()->postNotification(JoyStick_status,CCStringMake(JoyStick_attack));
}