本文整理汇总了C++中CCString::isEqual方法的典型用法代码示例。如果您正苦于以下问题:C++ CCString::isEqual方法的具体用法?C++ CCString::isEqual怎么用?C++ CCString::isEqual使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCString
的用法示例。
在下文中一共展示了CCString::isEqual方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showBoxCall
void SGWelComeLayer::showBoxCall(CCObject *obj)
{
if (obj)
{
CCDictionary *dict = (CCDictionary *)obj;
CCString *key = (CCString*)dict->objectForKey("key");
if(key->isEqual(CCString::create("RegisterSuccess"))
|| key->isEqual(CCString::create("BingSuccess")))
{
std::string str = CCUserDefault::sharedUserDefault()->getStringForKey("servername");
std::string account = CCUserDefault::sharedUserDefault()->getStringForKey("username");
changeServerbtn->setFont(str.c_str());
if (account.size() > NMAELIMIT) {
account = account.substr(0,NMAELIMIT-3);
account.append("...");
}
//只有不是facebook登陆的账号,才显示。
if (account.find("XD_THIRDPAR") == std::string::npos)
{
registerBtn->setFont(account.c_str());
}
}
else if(key->isEqual(CCString::create("serverList")))
{
CCString *serverName = (CCString*)dict->objectForKey("serverName");
CCString *serverIp = ((CCString*)dict->objectForKey("serverIp"));
CCString *serverId = (CCString*)dict->objectForKey("serverId");
CCString *serverPost = (CCString*)dict->objectForKey("serverPost");
serverDes = ( (CCString * )dict->objectForKey("serverDes"))->m_sString;
CCLOG("选中服务器名字: %s",serverName->getCString());
CCLOG("选中服务器Ip: %s",serverIp->getCString());
CCLOG("选中服务器Post: %s",serverPost->getCString());
CCLOG("选中服务器Id: %s",serverId->getCString());
CCUserDefault::sharedUserDefault()->setStringForKey("serverip", serverIp->getCString());
CCUserDefault::sharedUserDefault()->setIntegerForKey("serverpost", (short)serverPost->intValue());
CCUserDefault::sharedUserDefault()->setIntegerForKey("serverid", (short)serverId->intValue());
CCUserDefault::sharedUserDefault()->setStringForKey("servername", serverName->getCString());
CCUserDefault::sharedUserDefault()->flush();
//设置服务器名称
changeServerbtn->setFont(serverName->getCString());
//选一个服务器
if(m_pServerDict)
{
m_pServerDict->release();
}
m_pServerDict = dict;
m_pServerDict->retain();
}
}
}
示例2: CCString
LabelTTF::LabelTTF(const char* labelString, const char* filename, CCPoint location, CCSize dimensions, CCTextAlignment format) :
loadingValue("")
{
name = labelString;
fitType = ResizeFont;
fontFile = new CCString(filename);
fullFontFile = new CCString(filename);
alignment = format;
int sizeBegin = -1, sizeEnd = -1;
for(int i = 0; i < strlen(filename); i++)
{
bool isNumber = filename[i] >= '0' && filename[i] <= '9';
if(isNumber && sizeBegin == -1)
{
sizeBegin = i;
}
if(!isNumber && sizeBegin != -1 && sizeEnd == -1)
{
sizeEnd = i;
}
}
if(sizeEnd == -1 || sizeBegin == -1)
{
CCLOG("LabelTTF : incorrect font formating, use : FontnameSizeColor");
return;
}
CCString* fontFile = CCString::createWithData((const unsigned char*)filename, sizeBegin);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
//ios doesn't like full path and ttf extension
std::string fontFileWithoutTTF = fontFile->getCString();
int extensionPos = fontFileWithoutTTF.find_last_of(".ttf");
if(extensionPos != std::string::npos)
{
fontFileWithoutTTF = fontFileWithoutTTF.substr(0, extensionPos - 3);
}
int slashPos = fontFileWithoutTTF.find_last_of('/');
if(slashPos != std::string::npos)
{
fontFileWithoutTTF = fontFileWithoutTTF.substr(slashPos+1);
}
#endif
CCString* fontSize = CCString::createWithData((const unsigned char*)(filename + sizeBegin), sizeEnd - sizeBegin);
CCString* color = CCString::createWithData((const unsigned char*)(filename + sizeEnd), strlen(filename) - sizeEnd);
delegate = CCLabelTTF::create(labelString, fontFile->getCString(), fontSize->intValue());
delegate->retain();
delegate->setPosition(location);
delegate->setHorizontalAlignment(format);
ccColor3B color3B = color->isEqual(Screate("Gray")) ? ccGRAY : color->isEqual(Screate("White")) ? ccWHITE : ccBLACK;
delegate->setColor(color3B);
realDimensions = dimensions;
delegate->setDimensions(CCSizeMake(realDimensions.width / this->getScale(), 0));
delegate->enableUpdate(true);
this->adjustLabel();
}
示例3: callLuaFuncParReturn
//带参执行Lua方法有返回值
const char* SendLuaData::callLuaFuncParReturn(const char* luaFileName,const char* functionName,CCArray* arraypar,CCArray* arraypartype)
{
lua_State* ls = LuaEngine::defaultEngine()->getLuaStack()->getLuaState();
int isOpen = luaL_dofile(ls, getFileFullPath(luaFileName));
if(isOpen!=0){
CCLOG("Open Lua Error: %i", isOpen);
return NULL;
}
lua_getglobal(ls, functionName);
int countnum = arraypar->count();
if(countnum>0)
{
for (int i = 0; i<arraypar->count(); i++) {
CCString* typestr = (CCString*)arraypartype->objectAtIndex(i);
CCString* strnr = (CCString*)arraypar->objectAtIndex(i);
if(typestr->isEqual(CCString::create("string")))
{
lua_pushstring(ls, strnr->getCString());
}
else if(typestr->isEqual(CCString::create("int")))
{
lua_pushnumber(ls, strnr->intValue());
}
else if(typestr->isEqual(CCString::create("bool")))
{
lua_pushboolean(ls, strnr->boolValue());
}
}
}
/*
lua_call
第一个参数:函数的参数个数
第二个参数:函数返回值个数
*/
lua_call(ls, countnum, 1);
const char* iResult = lua_tostring(ls, -1);
return iResult;
}
示例4: initWithAnimation
void YYSprite::initWithAnimation(const std::string& aniFile,const std::string& pngFileName,const std::string& path){
const std::string aniPath = path +"/"+ aniFile + ".anu";
ani = YYAnimation::createAnimationWithFile(aniPath);
CCArray* array = split_string(pngFileName.c_str(),',');
pngFileNameArray = new CCArray(array->count());
for (int i = 0; i < array->count(); i++) {
CCString * str = (CCString*)array->objectAtIndex(i);
if (str->isEqual(new CCString(""))) {//处理空图片
pngFileNameArray-> addObject(new CCString("null"));
}else{
pngFileNameArray-> addObject(new CCString(path+"/"+str->getCString()+".png"));
}
}
if (ani->imageAmount != pngFileNameArray->count()) {
CCLog("error! imageAmount: %d,get imageCount:%d",ani->imageAmount,pngFileNameArray ->count());
}
// setFrameByID(0,false);
}
示例5: setMoudle
void YYSprite::setMoudle(int imgID ,CCRect rect, CCPoint position, unsigned char transform , int zOrder,bool isMirror){
CCString* pngFileName = (CCString*)pngFileNameArray-> objectAtIndex(imgID);
if (pngFileName->isEqual(new CCString("null"))) {//处理空图片
return;
}
CCSprite *sprite = CCSprite::create(pngFileName->getCString(), rect);
// sprite->texture->setAntiAliasTexParameters();
sprite->setPosition(position);
if(isMirror){
sprite->setScaleX(-1);
}
if (transform != 0) {
unsigned char transformType = (transform & 0x07 >> 1);
if (transformType == 1) {
sprite->setScaleY(-1);
}else if(transformType == 2){
sprite->setScaleX(-1);
}
}
示例6: tableCellAtIndex
CCTableViewCell* HelloWorld::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
CCDictionary* pRecipe = (CCDictionary*)m_pRecipes->objectAtIndex(idx);
CCString* pName = (CCString*)pRecipe->objectForKey("name");
CCString* pNo = (CCString*)pRecipe->objectForKey("recipe");
CCString* pStep = (CCString*)pRecipe->objectForKey("step");
CCString* string;
if (pStep!=NULL) {
string = CCString::createWithFormat("レシピ %s (ステップ%s): %s", pNo->getCString(), pStep->getCString(), pName->getCString());
} else if (pNo->isEqual(CCString::create("0"))) {
string = pName;
} else {
string = CCString::createWithFormat("レシピ %s : %s", pNo->getCString(), pName->getCString());
}
CCTableViewCell *cell = table->dequeueCell();
if (!cell) {
cell = new CCTableViewCell();
cell->autorelease();
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
int fontSize = CCEGLView::sharedOpenGLView()->getDesignResolutionSize().height/320.0f * 20;
CCLabelTTF *label = CCLabelTTF::create(string->getCString(), "Helvetica", fontSize, CCSizeMake(visibleSize.width, visibleSize.height/5), kCCTextAlignmentCenter);
label->setPosition(CCPointZero);
label->setAnchorPoint(CCPointZero);
label->setTag(123);
cell->addChild(label);
}
else
{
CCLabelTTF *label = (CCLabelTTF*)cell->getChildByTag(123);
label->setString(string->getCString());
}
return cell;
}
示例7: failCallBackFun
//失败回调
void GameStage::failCallBackFun(CCObject* data)
{
this->updateCombo();
this->updateScore();
this->updateHighScore();
this->layoutScoreNum(this->highScoreList, 2);
//this->newHighScore->stopAllActions();
CCNode* nNode = (CCNode*) data;
CCString* str = (CCString*)nNode->getUserData();
CCString* newRecordStr = new CCString(NEW_RECORD);
//判断2个字符串相等
if(str->isEqual(newRecordStr))
{
Cookie::getShareUserData()->setIntegerForKey("highScore", this->pukaManCore->highScore);
Cookie::getShareUserData()->flush();
this->newHighScore->stopAllActions();
this->newHighScore->setScale(0.0f);
CCActionInterval* scaleTo1 = CCScaleTo::create(0.5f, 1.0f);
CCDelayTime* delayTime = CCDelayTime::create(1.0f);
CCActionInterval* scaleTo2 = CCScaleTo::create(0.5f, 0.0f);
CCSequence* sequence = CCSequence::create(scaleTo1, delayTime, scaleTo2, NULL);
this->newHighScore->runAction(sequence);
}
}
示例8: showBoxCall
void SGHelpLayer::showBoxCall(CCObject *obj)
{
//不知道为什么需要加一个,返回的已经有了呀
SGMainLayer *mainLayer = (SGMainLayer *)SGMainManager::shareMain()->getMainScene()->getChildByTag(sg_mainLayer);
if (mainLayer) {
mainLayer->setIsCanTouch(true);
}
if (obj)
{
CCDictionary *dict = (CCDictionary *)obj;
CCString *key = (CCString*)dict->objectForKey("key");
if(key->isEqual(CCString::create("serverList")))
{
CCString *serverName = (CCString*)dict->objectForKey("serverName");
CCString *serverIp = ((CCString*)dict->objectForKey("serverIp"));
CCString *serverId = (CCString*)dict->objectForKey("serverId");
CCString *serverPost = (CCString*)dict->objectForKey("serverPost");
CCLOG("选中服务器名字: %s",serverName->getCString());
CCLOG("选中服务器Ip: %s",serverIp->getCString());
CCLOG("选中服务器Post: %s",serverPost->getCString());
CCLOG("选中服务器Id: %s",serverId->getCString());
CCUserDefault::sharedUserDefault()->setStringForKey("serverip", serverIp->getCString());
CCUserDefault::sharedUserDefault()->setIntegerForKey("serverpost", (short)serverPost->intValue());
CCUserDefault::sharedUserDefault()->setIntegerForKey("serverid", (short)serverId->intValue());
CCUserDefault::sharedUserDefault()->setStringForKey("servername", serverName->getCString());
CCUserDefault::sharedUserDefault()->flush();
std::string un = CCUserDefault::sharedUserDefault()->getStringForKey("username");
std::string pw = CCUserDefault::sharedUserDefault()->getStringForKey("password");
SGMainManager::shareMain()->setServerInfo(serverIp , (short)serverPost->intValue());
//SGHttpClient::shareHttpClient()->login(this, accountId, sid);
//OC调用改到外围
//#if (PLATFORM == IOS)
SGMainManager::shareMain()->dealIosLogin(un,pw);
// //OcCaller::getInstance()->pyUserSDKLoginReq(un.c_str(), pw.c_str());
//#else
// //android code
// SdkManager::shareSdkManager()->userLogin(un.c_str(), pw.c_str());
//#endif
/*
id sdkReqCallBack = SGMainManager::shareMain()->getSdkdelegate();
[[PYUserSDKLib sharedUserSDKLib] userLogin:[[NSString alloc] initWithUTF8String:un.c_str()]
Password:[[NSString alloc] initWithUTF8String:pw.c_str()]
GameId:@"1"
ChannelId:[sdkReqCallBack ChannelId]
SubChannelId:[sdkReqCallBack SubChannelId]
OsVersion:[sdkReqCallBack OsVersion]
OsType:[sdkReqCallBack OsType]
CallBackDelegate:sdkReqCallBack FinishSelector:@selector(loginFinished:) FailSelector:@selector(requestFailed:)];
*/
}
}
}
示例9: if
//CCDictionary* dict = NULL;
//CCObject *pObject = NULL;
CCARRAY_FOREACH(pChildrenArray,pObject)
{
dict = (CCDictionary *)pObject;
if(!dict)
break;
const char* key = "name";
CCString* name = (CCString*)dict->objectForKey(key);
if(name->isEqual(CCString::create("fire")))
{
key = "x";
int x = ((CCString*)dict->objectForKey(key))->intValue();
key = "y";
int y = ((CCString*)dict->objectForKey(key))->intValue();
addFire(ccp(x,y));
}else if(name->isEqual(CCString::create("monster")))
{
key = "x";
int x = ((CCString*)dict->objectForKey(key))->intValue();
key = "y";
int y = ((CCString*)dict->objectForKey(key))->intValue();
key = "plistname";
CCString* temp = ((CCString*)dict->objectForKey(key));
string* plistname = new string(temp->getCString());
plistname->append(".plist");
string* spritename = new string(temp->getCString());
spritename->append("_%d.png");
MySprite* sprite = MySprite::getInstance(ccp(x,y),plistname->c_str(),spritename->c_str(),m_pMyworld);
key = "enemy";
sprite->setType(((CCString*)dict->objectForKey(key))->isEqual(CCString::create("true")));//设置 敌人
sprite->setTag(m_iMosterSpriteTag);
if (((CCString*)dict->objectForKey(key))->isEqual(CCString::create("true"))){//如果是敌人
m_iResuduoMonsterNum++;
sprite->setCallbackFunc(this,callfunc_selector(GameSceneLayer::gameVictory));
}else{
sprite->setCallbackFunc(this,callfunc_selector(GameSceneLayer::gameFaild));
}
this->addChild(sprite);
delete plistname;
delete spritename;
}else if(name->isEqual(CCString::create("wood")))
{
key = "x";
int x = ((CCString*)dict->objectForKey(key))->intValue();
key = "y";
int y = ((CCString*)dict->objectForKey(key))->intValue();
key = "sprite_name";
CCString* sprite_name= (CCString*)dict->objectForKey(key);
MyObject* sprite = MyObject::getInstance(ccp(x,y),sprite_name->getCString(),m_pMyworld,MyObject::WOOD);
this->addChild(sprite);
}else if(name->isEqual(CCString::create("iron_v")))
{
key = "x";
int x = ((CCString*)dict->objectForKey(key))->intValue();
key = "y";
int y = ((CCString*)dict->objectForKey(key))->intValue();
key = "bottom";
int bottom = ((CCString*)dict->objectForKey(key))->intValue();
key = "speed";
int speed = ((CCString*)dict->objectForKey(key))->intValue();
key = "top";
int top = ((CCString*)dict->objectForKey(key))->intValue();
MyObject* sprite = MyObject::getInstance(ccp(x,y),"iron_v.png",m_pMyworld,MyObject::IRON_V);
sprite->setProperties(ccp(0,speed),ccp(top,bottom),ccp(0,0));
this->addChild(sprite);
}else if(name->isEqual(CCString::create("iron_h")))
{
key = "x";
int x = ((CCString*)dict->objectForKey(key))->intValue();
key = "y";
int y = ((CCString*)dict->objectForKey(key))->intValue();
key = "left";
int left = ((CCString*)dict->objectForKey(key))->intValue();
key = "speed";
int speed = ((CCString*)dict->objectForKey(key))->intValue();
key = "right";
int right = ((CCString*)dict->objectForKey(key))->intValue();
MyObject* sprite = MyObject::getInstance(ccp(x,y),"iron_h.png",m_pMyworld,MyObject::IRON_H);
sprite->setProperties(ccp(speed,0),ccp(0,0),ccp(left,right));
this->addChild(sprite);
}else if(name->isEqual(CCString::create("triangle")))
{
key = "x";
int x = ((CCString*)dict->objectForKey(key))->intValue();
key = "y";
int y = ((CCString*)dict->objectForKey(key))->intValue();
MyObject* sprite = MyObject::getInstance(ccp(x,y),"triangle.png",m_pMyworld,MyObject::TRIANGLE);
this->addChild(sprite);
}else if(name->isEqual(CCString::create("circle")))
//.........这里部分代码省略.........
示例10: init
bool Troop::init() {
do {
CC_BREAK_IF(!CCLayer::init());
this->autorelease();
removeQueue = CCArray::create();
removeQueue->retain();
petTypes = Utils::getPetTypes();
//init pets array
pets = CCArray::createWithCapacity(2 * cap);
vlinks = CCArray::createWithCapacity(cap);
hlinks = CCArray::createWithCapacity(cap);
pets->retain();
vlinks->retain();
hlinks->retain();
//todo: 可能出现某一个节点没有可用类型的情况,这种情况重新初始化
for (int i = 0; i < cap; i++) {
vlinks->addObject(CCArray::create());
hlinks->addObject(CCArray::create());
CCArray* availTypes = CCArray::createWithArray(petTypes);
int v = i;
int h = i;
for (int j = i - col; j >= 0 && j >= i - 2*col; j -= col) {
CCArray* vlink = (CCArray*)vlinks->objectAtIndex(j);
int size = vlink->count();
if (size == 0) {
continue;
} else if (size >= 2) {
Utils::removeStringFromArray(availTypes, ((Pet*)vlink->objectAtIndex(0))->getType());
break;
}
}
if (i%col != 0) {
for (int j = i - 1; j >= 0 && j >= i - 2; j--) {
CCArray* hlink = (CCArray*)hlinks->objectAtIndex(j);
int size = hlink->count();
if (size == 0) {
continue;
} else if (size >= 2) {
Utils::removeStringFromArray(availTypes, ((Pet*)hlink->objectAtIndex(0))->getType());
break;
}
}
}
CCString* petType = (CCString*)availTypes->randomObject();
if (i >= col && petType->isEqual(getPetAtIndex(i - col)->getType())) {
v -= col;
}
if (i > 0 && i % 7 != 0 && petType->isEqual(getPetAtIndex(i - 1)->getType())) {
h--;
}
Pet* pet = new Pet(petType, i);
pet->setVLink(v);
pet->setHLink(h);
((CCArray*)vlinks->objectAtIndex(v))->addObject(pet);
((CCArray*)hlinks->objectAtIndex(h))->addObject(pet);
pets->addObject(pet);
int c = i % 7;
int r = 3 - i / 7;
pet->setPosition(ccp(Unit::GRID_SIZE * c + Unit::GRID_SIZE/2, Unit::GRID_SIZE * r + Unit::GRID_SIZE/2));
addChild(pet);
}
for (int i = cap; i < 2 * cap; i++) {
pets->addObject(Pet::createFakePet());
}
selectedPet = NULL;
return true;
} while (0);
return false;
}
示例11: _GetColorByName
//--------------------------------------------------------
ccColor3B CListControllerLayer::_GetColorByName(std::string p_szName)
{
CCArray a;
a.addObjectsFromArray( &FKCW_Base_Utils::ComponentOfString(p_szName, '_') );
if( a.count() >= 3 )
{
CCString* FKCWHead = (CCString*)a.objectAtIndex(0);
CCString* SmallType = (CCString*)a.objectAtIndex(1);
if(! FKCWHead->isEqual(ccs("FKCW")) )
return ccc3(225,238,210);
if(SmallType->isEqual(ccs("UI")))
return ccc3(230, 155, 3);
else if(SmallType->isEqual(ccs("Action")))
return ccc3(209, 73, 78);
else if(SmallType->isEqual(ccs("UIWidget")))
return ccc3(131, 175, 155);
else if(SmallType->isEqual(ccs("Base")))
return ccc3(249, 205, 173);
else if(SmallType->isEqual(ccs("EffectNode")))
return ccc3(175, 215, 237);
else if(SmallType->isEqual(ccs("RenderEx")))
return ccc3(175, 18, 88);
else if(SmallType->isEqual(ccs("GR")))
return ccc3(130, 57, 53);
else if(SmallType->isEqual(ccs("Database")))
return ccc3(160, 191, 124);
else if(SmallType->isEqual(ccs("Network")))
return ccc3(255, 252, 153);
else if(SmallType->isEqual(ccs("Json")))
return ccc3(87, 105, 60);
else if(SmallType->isEqual(ccs("Font")))
return ccc3(230, 155, 3);
else if(SmallType->isEqual(ccs("SimpleNet")))
return ccc3(209, 73, 78);
else if(SmallType->isEqual(ccs("SceneEx")))
return ccc3(175, 215, 237);
else if(SmallType->isEqual(ccs("3D")))
return ccc3(64, 116, 52);
else if(SmallType->isEqual(ccs("RichHtml")))
return ccc3(249, 205, 173);
else if(SmallType->isEqual(ccs("Story")))
return ccc3(131, 175, 155);
else if(SmallType->isEqual(ccs("Pixel")))
return ccc3(175, 18, 88);
}
return ccc3(225,238,210);
}