bool Character::checkUpward(RMTiledMap *tiledMap, CCPoint currenPos){ if(currenPos.y <= 0) return false; CCString *type = tiledMap->typeAtTileCoord(ccp(currenPos.x, currenPos.y - 1)); if (type && (type->compare("1") == 0 || type->compare("2") == 0)) { return true; } else if(type == NULL){ return true; } else return false; }
bool Character::checkRight(RMTiledMap *tiledMap, CCPoint currenPos){ if(currenPos.x >= WIDTH - 1 && currenPos.y == 13){ return true; } if(currenPos.x >= WIDTH - 1) return false; CCString *type = tiledMap->typeAtTileCoord(ccp(currenPos.x + 1 , currenPos.y)); if (type && (type->compare("1") == 0 || type->compare("2") == 0) && currenPos.x < WIDTH - 1) { return true; } else if(type == NULL){ return true; } else return false; }
// do not move to Player.h void Game::setPlayerPosition(CCPoint position, CCFiniteTimeAction* sequence) { CCPoint tileCoord = this->tileCoordForPosition(position); int tileGid = _meta->tileGIDAt(tileCoord); if (tileGid) { CCDictionary *properties = _tileMap->propertiesForGID(tileGid); if (properties) { // obstacle CCString *collision = new CCString(); *collision = *properties->valueForKey("Collidable"); // Moveable CCString *move = new CCString(); *move = *properties->valueForKey("Moveable"); // Breakable CCString *breakable = new CCString(); *breakable = *properties->valueForKey("Breakable"); if ((collision && collision->compare("True") == 0) || (move && move->compare("True") == 0) || (breakable && breakable->compare("True") == 0)) { // 動けない音を出す CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("hit.caf"); this->finishAnimation(); CCLog("Can't move"); return; } // item get CCString *collectable = new CCString(); *collectable = *properties->valueForKey("Collectable"); if (collectable && (collectable->compare("True") == 0)) { // 取り除く _meta->removeTileAt(tileCoord); _foreground->removeTileAt(tileCoord); _numCollected++; _hud->numCollectedChanged(_numCollected); CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("pickup.caf"); } } } _player->runAction(sequence); // not hit only 赤にする this->setTileEffect(position); CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("move.caf"); }
void MoreDiamondDialog::onRateCompleted( CCNode *sender, void *data ) { if (data != NULL) { CCDictionary *convertedData = (CCDictionary *)data; CCString* s = (CCString*)convertedData->objectForKey("isSuccess"); if (s->boolValue()) { CCLOG("CPP Rate Completed: TRUE"); CCString* s = (CCString*)convertedData->objectForKey("responseType"); CCLOG("%s", s->getCString()); if (s->compare("RATE") == 0) { CCMessageBox( CCString::createWithFormat("Bạn được nhận +%d kim cương.", CONF_INT(DIAMOND_FOR_RATE))->getCString(), "Thưởng"); DataManager::sharedDataManager()->AddDiamond(CONF_INT(DIAMOND_FOR_RATE)); DataManager::sharedDataManager()->SetIsRatedApp(true); m_itlbRate->setEnabled(false); m_itlbRate->setOpacity(100); } } else { CCLOG("CPP Rate Completed: FALSE"); } NDKHelper::RemoveSelector("MoreDiamondDialog", "onRateCompleted"); } }
bool CSpriteObject::init(CCDictionary* pObjectDict) { do { CC_BREAK_IF(!CObjectBase::init(pObjectDict)); CCString* fileType = getFileTypeFromDict(); CC_BREAK_IF(NULL == fileType); CCString* fileName = getFileNameFromDict(); CC_BREAK_IF(NULL == fileName); if (getMaxLevelFromDict() > 0) { fileName = CCString::createWithFormat("%s%d", fileName->getCString(), getLevel() - 1); } if (fileType->compare("ccbi") == 0) { fileName = CCString::createWithFormat("%s.ccbi", fileName->getCString()); CC_BREAK_IF(!setSpriteFromCcbi(fileName->getCString())); } else { CC_BREAK_IF(!setSprite(fileName->getCString())); } return true; } while (false); return false; }
void RestartLayer::show() { CCString* str = CCString::createWithFormat("IQ: %d", m_nIQ); m_pIQLabel->setString(str->getCString()); NavigatorLayer::show(); m_pHead->stopAllActions(); m_pHead->runAction(m_pFlickerAction); #if CC_TARGET_PLATFORM == CC_PLATFORM_IOS CCString *promptText = getScene()->getPromptText(); if(promptText->compare("") == 0) { if(m_pPromptItem) { m_pPromptItem->setVisible(false); } } else { if(m_pPromptText) m_pPromptText->setVisible(false); m_pHead->setVisible(true); } #endif }
const char* BackPack::getItmType(const char* filename) { // return monster, obstacle, or health type item CCString* nameCheck; //CCLog("filename is %s",filename); // run loop to find matching filename in m_asItems for (int i=0 ; i < sizeof(m_asItems)/TOTAL_ITEMS ; i++) // divide by the size of the struct to get length { nameCheck = CCString::createWithFormat("%s",m_asItems[i].filename); //CCLog("%s",m_asItems[i].filename); //if (m_asItems[i].filename == NULL || m_asItems[i].stock == 0); // use compare fxn for strings if (nameCheck->compare(filename) == 0) { //CCLog("got a match"); // return type (monster, obstacle, or "") if (m_asItems[i].type == NULL) return ""; else return m_asItems[i].type; } } return NULL; }
void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { m_pCustomProperties->removeAllObjects(); int numRegularProps = pCCBReader->readInt(false); int numExturaProps = pCCBReader->readInt(false); int propertyCount = numRegularProps + numExturaProps; for(int i = 0; i < propertyCount; i++) { bool isExtraProp = (i >= numRegularProps); int type = pCCBReader->readInt(false); std::string propertyName = pCCBReader->readCachedString(); // Check if the property can be set for this platform bool setProp = false; int platform = pCCBReader->readByte(); if(platform == kCCBPlatformAll) { setProp = true; } // Cocos2d-x is using touch event callback for all platforms, // it's different from cocos2d-iphone which uses mouse event for Mac port. // So we just need to touch event by using kCCBPlatformIOS. //#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) if(platform == kCCBPlatformIOS) { setProp = true; } // #elif (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) // if(platform == kCCBPlatformMac) // { // setProp = true; // } // #endif // Forward properties for sub ccb files if (dynamic_cast<CCBFile*>(pNode) != NULL) { CCBFile *ccbNode = (CCBFile*)pNode; if (ccbNode->getCCBFileNode() && isExtraProp) { pNode = ccbNode->getCCBFileNode(); // Skip properties that doesn't have a value to override CCArray *extraPropsNames = (CCArray*)pNode->getUserObject(); CCObject* pObj = NULL; bool bFound = false; CCARRAY_FOREACH(extraPropsNames, pObj) { CCString* pStr = (CCString*)pObj; if (0 == pStr->compare(propertyName.c_str())) { bFound = true; break; } } setProp &= bFound; }
virtual float32 ReportFixture(b2Fixture* fixture, const b2Vec2& point, const b2Vec2& normal, float32 fraction) { CCString* name = b2Helper::getBodyName(fixture->GetBody()); if (name->compare("hill") == 0) { Steven* steven = Steven::sharedSteven(); steven->mSkiHigh = (steven->m_pB2Body->GetWorldCenter().y - point.y) * G.PTM_RATIO - mRadius; return 0; } return 1; }
bool GameWorld::checkCollision(int tileGID) { if (tileGID > 0) { ValueMap tileValues = _tileMap->getPropertiesForGID(tileGID).asValueMap(); CCString* testme = new CCString(); *testme = tileValues.at("Collidable").asString(); if ((testme->length()) > 0 && (testme->compare("True") == 0)) { return true; } } return false; }
void CCPurchasableVirtualItem::fillPurchaseTypeFromDict(CCDictionary *dict) { CCDictionary *purchasableDict = dynamic_cast<CCDictionary *>(dict->objectForKey(JSON_PURCHASABLE_ITEM)); CC_ASSERT(purchasableDict); CCString* purchaseTypeStr = dynamic_cast<CCString *>(purchasableDict->objectForKey(JSON_PURCHASE_TYPE)); CCAssert(purchaseTypeStr != NULL, "invalid object type in dictionary"); if (purchaseTypeStr->compare(JSON_PURCHASE_TYPE_MARKET) == 0) { CCDictionary *marketItemDict = dynamic_cast<CCDictionary *>(purchasableDict->objectForKey(JSON_PURCHASE_MARKET_ITEM)); CC_ASSERT(marketItemDict); setPurchaseType(CCPurchaseWithMarket::createWithMarketItem( CCMarketItem::createWithDictionary(marketItemDict))); } else if (purchaseTypeStr->compare(JSON_PURCHASE_TYPE_VI) == 0) { CCString *itemId = dynamic_cast<CCString *>(purchasableDict->objectForKey(JSON_PURCHASE_VI_ITEMID)); CC_ASSERT(itemId); CCInteger *amount = dynamic_cast<CCInteger *>(purchasableDict->objectForKey(JSON_PURCHASE_VI_AMOUNT)); CC_ASSERT(amount); setPurchaseType(CCPurchaseWithVirtualItem::create(itemId, amount)); } else { CCLog("Couldn't determine what type of class is the given purchaseType."); } }
CCTexture2D * CCNodeLoader::parsePropTypeTexture(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { CCString * spriteFile = pCCBReader->readCachedString(); if (spriteFile->compare("") != 0) { return CCTextureCache::sharedTextureCache()->addImage(spriteFile->getCString()); } else { return NULL; } }
void HelloWorld::setPlayerPosition(CCPoint position) { CCPoint tileCoord = this->tileCoordForPosition(position); int tileGid = _meta->tileGIDAt(tileCoord); if (tileGid) { CCDictionary *properties = _tileMap->propertiesForGID(tileGid); if (properties) { CCString *collision = new CCString(); *collision = *properties->valueForKey("Collidable"); if (collision && (collision->compare("true") == 0)) { return; } CCString *collectible = new CCString(); *collectible = *properties->valueForKey("Collectable"); if (collectible && (collectible->compare("true") == 0)) { _meta->removeTileAt(tileCoord); } } } _player->setPosition(position); }
int BackPack::getItmStock(const char* filename, bool zeros) { //return item amount currently in stock int check = 0; CCString* nameCheck; //CCLog("filename is %s",filename); // run loop to find matching filename in m_asItems for (int i=0 ; i < sizeof(m_asItems)/TOTAL_ITEMS ; i++) // divide by the size of a struct to get length { nameCheck = CCString::createWithFormat("%s",m_asItems[i].filename); //CCLog("%s",m_asItems[i].filename); if (zeros == true) if (m_asItems[i].filename == NULL); else { // use compare fxn for strings if (nameCheck->compare(filename) == 0) { //CCLog("got a match"); check = m_asItems[i].stock; } } else if (zeros == false) if (m_asItems[i].filename == NULL || m_asItems[i].stock == 0); else { // use compare fxn for strings if (nameCheck->compare(filename) == 0) { //CCLog("got a match"); check = m_asItems[i].stock; } } } return check; }
Price createPriceWithDictionary(CCDictionary * dict) { Price::CoinType coinType; uint32 value; CCString * strType = (CCString *)dict->objectForKey(PRICE_TYPE_KEY); if (strType->compare(PRICE_COIN) == 0) { coinType = Price::kCoinType_Coin; } else if (strType->compare(PRICE_GEM) == 0) { coinType = Price::kCoinType_Gem; } else { coinType = Price::kCoinType_Unknown; } CCString * strNumber = (CCString *)dict->objectForKey(PRICE_VALUE_KEY); value = strNumber->uintValue(); return Price(coinType, value); }
bool CC3STBImage::shouldUseForFileExtension( const std::string& fileExtension ) { CCSet* pExtensions = useForFileExtensions(); CCString *pExt; CCSetIterator setIter; for (setIter = pExtensions->begin(); setIter != pExtensions->end(); ++setIter) { pExt = (CCString *)(*setIter); if ( pExt->compare( fileExtension.c_str() ) == 0 ) return true; } return false; }
void BackPack::useItmStock(const char* filename) { // Use an item CCString* nameCheck; //CCLog("filename is %s",filename); // run loop to find matching filename in m_asItems for (int i=0 ; i < sizeof(m_asItems)/TOTAL_ITEMS ; i++) // divide by the size of the struct to get length { nameCheck = CCString::createWithFormat("%s",m_asItems[i].filename); //CCLog("%s",m_asItems[i].filename); //if (m_asItems[i].filename == NULL || m_asItems[i].stock == 0); // use compare fxn for strings if (nameCheck->compare(filename) == 0) { //CCLog("got a match"); // reduce stock by 1 m_asItems[i].stock-=1; } } }
CCAnimation * CCNodeLoader::parsePropTypeAnimation(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { CCString * animationFile = pCCBReader->readCachedString(); CCString * animation = pCCBReader->readCachedString(); CCAnimation * ccAnimation = NULL; // Support for stripping relative file paths, since ios doesn't currently // know what to do with them, since its pulling from bundle. // Eventually this should be handled by a client side asset manager // interface which figured out what resources to load. // TODO Does this problem exist in C++? animation = CCBReader::lastPathComponent(animation); animationFile = CCBReader::lastPathComponent(animationFile); if (animation != NULL && animation->compare("") != 0) { CCAnimationCache * animationCache = CCAnimationCache::sharedAnimationCache(); animationCache->addAnimationsWithFile(animationFile->getCString()); ccAnimation = animationCache->animationByName(animation->getCString()); } return ccAnimation; }
int BackPack::getItmDice(const char* filename) { // return dice bonus amount CCString* nameCheck; //CCLog("filename is %s",filename); // run loop to find matching filename in m_asItems for (int i=0 ; i < sizeof(m_asItems)/TOTAL_ITEMS ; i++) // divide by the size of the struct to get length { nameCheck = CCString::createWithFormat("%s",m_asItems[i].filename); //CCLog("%s",m_asItems[i].filename); //if (m_asItems[i].filename == NULL || m_asItems[i].stock == 0); // use compare fxn for strings if (nameCheck->compare(filename) == 0) { //CCLog("got a match"); // return dice number return m_asItems[i].dice; } } return NULL; }
// 赤をタップした? void Game::attackBlock(CCPoint point) { CCPoint tileCoord = this->tileCoordForPosition(point);; int tileGid = _meta->tileGIDAt(tileCoord); if (tileGid) { CCDictionary *properties = _tileMap->propertiesForGID(tileGid); if (properties) { // obstacle CCString *collision = new CCString(); *collision = *properties->valueForKey("Collidable"); // Moveable //CCString *move = new CCString(); //*move = *properties->valueForKey("Moveable"); // Breakable CCString *breakable = new CCString(); *breakable = *properties->valueForKey("Breakable"); // 殴れる判定 if (breakable && breakable->compare("True") == 0) { //if (collision && (collision->compare("True") == 0)) { CCLog("Attackable"); // TODO: // ブロック消す //_meta->removeTileAt(tileCoord); //_foreground->removeTileAt(tileCoord); /*CCSprite *sprite = _background->tileAt(tileCoord); if(sprite->getTag() == TAPPABLE) { CCLog("OKsssss"); }*/ } } } }
// Breakable(破壊可能)のタイルを赤にする void Game::setTileEffect(CCPoint position) { // stage and area _hud->setStageLabel(1, 1); _hud->setLifeLabel(1); CCPoint tileCoord = this->tileCoordForPosition(position); // キャラクターの上下左右の座標 CCPointArray *pointArray = CCPointArray::create(4); pointArray->addControlPoint(ccp(0,1)); pointArray->addControlPoint(ccp(-1,0)); pointArray->addControlPoint(ccp(1,0)); pointArray->addControlPoint(ccp(0,-1)); for(int i = 0; i < pointArray->count(); i++){ CCPoint point = pointArray->getControlPointAtIndex(i); //CCLog("(%f,%f)", point.x, point.y); CCPoint tmpTileCoord = ccp(tileCoord.x + point.x, tileCoord.y + point.y); if(tmpTileCoord.x < 0 || tmpTileCoord.x > _tileMap->getMapSize().width -1 || tmpTileCoord.y < 0 || tmpTileCoord.y > _tileMap->getMapSize().height - 1) { continue; } //CCLog("(%f,%f)", tmpTileCoord.x, tmpTileCoord.y); //CCLog("TileX %f, TileY %f", _tileMap->getMapSize().width, _tileMap->getMapSize().height); int tileGid = _meta->tileGIDAt(tmpTileCoord); if (tileGid) { CCDictionary *properties = _tileMap->propertiesForGID(tileGid); if (properties) { // obstacle CCString *collision = new CCString(); // Breakableを赤 *collision = *properties->valueForKey("Breakable"); if (collision && (collision->compare("True") == 0)) { CCSprite *sprite = _background->tileAt(tmpTileCoord); //sprite->setTag(TAPPABLE); // red sprite->setColor(ccRED); } } } } // 白に戻す // まず詰める /* ◯は赤なので変化させない |6,0|6,1|6,2|6,3|6,4|6,5|6,6| |5,0|5,1|5,2|5,3|5,4|5,5|5,6| |4,0|4,1|4,2|◯4,3|4,4|4,5|4,6| |3,0|3,1|◯3,2|3,3|◯3,4|3,5|3,6| |2,0|2,1|2,2|◯2,3|2,4|2,5|2,6| |1,0|1,1|1,2|1,3|1,4|1,5|1,6| |0,0|0,1|0,2|0,3|0,4|0,5|0,6| */ CCPointArray *revertPointArray = CCPointArray::create(255); for (int i = 0; i < 7; i++) { for (int j = 0; j < 7; j++) { if((i == 3 && j == 2) || (i == 3 && j == 4) || (i == 2 && j == 3) || (i == 4 && j == 3) ) { continue; } revertPointArray->addControlPoint(ccp(-3 + j, -3 + i)); } } // 詰めたものから適用 for(int i = 0; i < revertPointArray->count(); i++) { CCPoint point = revertPointArray->getControlPointAtIndex(i); //CCLog("(%f,%f)", point.x, point.y); CCPoint tmpTileCoord = ccp(tileCoord.x + point.x, tileCoord.y + point.y); // 画面端はエラーになるので適用させない if(tmpTileCoord.x < 0 || tmpTileCoord.x > _tileMap->getMapSize().width - 1|| tmpTileCoord.y < 0 || tmpTileCoord.y > _tileMap->getMapSize().height - 1) { continue; } //CCLog("(%f,%f)", tmpTileCoord.x, tmpTileCoord.y); int tileGid = _meta->tileGIDAt(tmpTileCoord); if (tileGid) { CCDictionary *properties = _tileMap->propertiesForGID(tileGid); if (properties) { // obstacle CCString *collision = new CCString(); // Breakableのみ戻す *collision = *properties->valueForKey("Breakable"); if (collision && (collision->compare("True") == 0)) { CCSprite *sprite = _background->tileAt(tmpTileCoord); // 白で塗る sprite->setColor(ccWHITE); //sprite->setTag(NOT_TAPPABLE); } } } } }
void loadNodeToFenneX(Node* baseNode, Panel* parent) { GraphicLayer* layer = GraphicLayer::sharedLayer(); if(parent == NULL) { layer->useBaseLayer((Layer*)baseNode); #if VERBOSE_LOAD_CCB CCLOG("replaced base layer by CCB node : position : %f, %f, scale : %f", baseNode->getPosition().x, baseNode->getPosition().y, baseNode->getScale()); #endif } //Use an index because InputLabel modify the array, so you need to rewind a bit at some point for(int i = 0; i < baseNode->getChildren().size(); i++) { Node* node = baseNode->getChildren().at(i); #if VERBOSE_LOAD_CCB CCLOG("doing child %d from parent %s ...", i, parent != NULL ? parent->getName() != "" ? parent->getName().c_str() : "Panel" : "base layer"); #endif RawObject* result = NULL; if(isKindOfClass(node, Label)) { Label* label = (Label*)node; #if VERBOSE_LOAD_CCB CCLOG("label, font : %s", label->getSystemFontName().c_str()); #endif CCString* translationKey = isKindOfClass(label, CustomBaseNode) ? (CCString*)dynamic_cast<CustomBaseNode*>(label)->getParameters()->objectForKey("translationKey") : NULL; const std::string translated = Localization::getLocalizedString(translationKey != NULL ? translationKey->getCString() : label->getString()); if(translationKey == NULL || translationKey->compare(translated.c_str()) != 0) { //Don't replace the string if it's the same, as it may only be a key, not a real label label->setString(translated); } result = layer->createLabelTTFromLabel(label, parent); } else if(isKindOfClass(node, CustomDropDownList)) { #if VERBOSE_LOAD_CCB CCLOG("DropDownList"); #endif Sprite* sprite = (Sprite*)node; result = layer->createDropDownListFromSprite(sprite, parent); } else if(isKindOfClass(node, Sprite)) { #if VERBOSE_LOAD_CCB CCLOG("image"); #endif Sprite* sprite = (Sprite*)node; result = layer->createImageFromSprite(sprite, parent); } else if(isKindOfClass(node, CustomInput)) { #if VERBOSE_LOAD_CCB CCLOG("input label"); #endif ui::Scale9Sprite* sprite = (ui::Scale9Sprite*)node; CCString* translationKey = isKindOfClass(sprite, CustomBaseNode) ? (CCString*)dynamic_cast<CustomBaseNode*>(sprite)->getParameters()->objectForKey("translationKey") : NULL; std::string placeHolder = isKindOfClass(sprite, CustomInput) ? ((CustomInput*) sprite)->getPlaceHolder()->getCString() : ""; result = layer->createInputLabelFromScale9Sprite(sprite, parent); const std::string text = Localization::getLocalizedString(translationKey != NULL ? translationKey->getCString() : placeHolder.c_str()); if(translationKey == NULL || translationKey->compare(text.c_str()) != 0) { ((InputLabel*) result)->setInitialText(text); } i--; } else if(isKindOfClass(node, ui::Scale9Sprite)) { #if VERBOSE_LOAD_CCB CCLOG("scale sprite"); #endif ui::Scale9Sprite* sprite = (ui::Scale9Sprite*)node; result = layer->createCustomObjectFromNode(sprite, parent); } else if(!isKindOfClass(node, ui::EditBox)) { #if VERBOSE_LOAD_CCB CCLOG("Edit Box"); #endif result = layer->createPanelFromNode(node, parent); } #if VERBOSE_LOAD_CCB if(result != NULL) { CCLOG("Child %d loaded : position : %f, %f, scale : %f", i, result->getPosition().x, result->getPosition().y, result->getScale()); } else { CCLOG("Problem loading child %d !", i); } #endif } }
void LotteryRotateView::getCmdData(CCObject *pObj) { CCString* reward = CCString::create(""); if (LotteryController::shared()->rotateType==1) {//0-普通,1-连转10次 m_save10Arr = dynamic_cast<CCArray*>(pObj); LotteryController::shared()->m_save10Arr = dynamic_cast<CCArray*>(pObj); if(m_save10Arr && m_save10Arr->count()>0){ CCDictionary* lastDict = dynamic_cast<CCDictionary*>(m_save10Arr->objectAtIndex(m_save10Arr->count()-1)); int dictType = lastDict->valueForKey("type")->intValue(); CCDictionary* rewardsDic = _dict(lastDict->objectForKey("result")); /* 里面的type 是 RESOURCE, BOX_TIMES, REWARD 0 1 2*/ if (dictType == 0) {//RESOURCE int resType = rewardsDic->valueForKey("type")->intValue(); reward = CCString::create(CC_ITOA(resType)); }else if (dictType == 1){//BOX_TIMES reward = CCString::create(CC_ITOA(100)); }else if (dictType == 2){//REWARD int resType = rewardsDic->valueForKey("type")->intValue(); if (resType == 7) { CCDictionary* valueDic = _dict(rewardsDic->objectForKey("value")); int itemId = valueDic->valueForKey("itemId")->intValue(); reward = CCString::create(CC_ITOA(itemId)); }else{ reward = CCString::create(CC_ITOA(resType)); } } } }else{ reward = dynamic_cast<CCString*>(pObj); } CCLOG("reward:%s",reward->getCString()); if (!reward || (reward && reward->compare("error")==0)) { m_targetCell = NULL; CCDictionary* dict = CCDictionary::create(); dict->setObject(ccs(LOTTERYACTVIEW_COM), "key"); dict->setObject(ccs("error"), "value"); CCSafeNotificationCenter::sharedNotificationCenter()->postNotification(LOTTERYROTATEVIEW, dict); // rotateFinished(); this->unschedule(schedule_selector(LotteryRotateView::rotatingHandler)); m_rotating = false; return; } float rotateAngleArr[12] = {0, 30, 60, 90, 120, 150, 180, -150, -120, -90, -60, -30}; float rotateAngle = 0.0f; LotteryActCell* cell2 = NULL; bool getTarget = false; for (int i = 0; i < m_pContainer->getChildrenCount(); i++) { cell2 = dynamic_cast<LotteryActCell*>(m_pContainer->getChildByTag(i)); if (cell2) { rotateAngle = rotateAngleArr[i]; cell2->setAngle(CC_DEGREES_TO_RADIANS(rotateAngle)); if (!getTarget && reward->compare(cell2->getItemId().c_str())==0) { m_targetCell = cell2; getTarget = true; } } } doCellSort(); if (m_targetCell == NULL) { // rotateFinished(); this->unschedule(schedule_selector(LotteryRotateView::rotatingHandler)); m_rotating = false; CCDictionary* dict = CCDictionary::create(); dict->setObject(ccs(LOTTERYACTVIEW_COM), "key"); dict->setObject(ccs("error"), "value"); CCSafeNotificationCenter::sharedNotificationCenter()->postNotification(LOTTERYROTATEVIEW, dict); return; } int index = m_targetCell->getTag(); // 基准角度 float addAngle = 0.0; if (LotteryController::shared()->rotateType==1) {//0-普通,1-连转10次 // addAngle = 360; } if (m_tScrollAngel > 0) { m_fEndAngle = -(index+3)*30 + addAngle + (1 + ((int) m_speed3/360)) * 360.0f;//720 } else { m_fEndAngle = -(index+3)*30.0f - addAngle - (1 + ((int) m_speed3/360)) * 360.0f;//360 } m_fEndTime3 = fabs(m_fEndAngle)/m_speed3;// 一圈的时间 m_fTimeCnt3 = (int) (m_fEndTime3/m_fTimeGap3)*1.3; // if (LotteryController::shared()->rotateType==1) {//0-普通,1-连转10次 // addRewardsNodeBg(); // } // if (m_fTimeCnt3 > 300) // { // m_fTimeCnt3 = m_fTimeCnt3/2; // } m_fTimeIdx3 = 0; m_rotateAngle = 0; m_hasGetReward = true; }