Пример #1
0
void Picking::displayEnemy()
{
    auto fileU = FileUtils::getInstance();
    auto fileContent = fileU->getStringFromFile("data/animData.xml");
    doc.Parse(fileContent.c_str());

    UserDefault* def = UserDefault::getInstance();
    enemyMonster = def->getIntegerForKey(SaveDataKey[(n_DataKeyNum::eEnemyMonster01) + m_battleNum].c_str());

    auto sprite = doc.FirstChildElement()->FirstChildElement(MonsterNameData[enemyMonster].c_str());

    /*
    //CARD on the center
    m_enemySpecial = Sprite::create("img/UI/battle/UI_B_12.png");
    m_enemySpecial->setScale(m_Mag * 0.8);
    m_enemySpecial->setPosition(Vec2(m_visibleSize.width / 2, m_visibleSize.height - m_enemySpecial->getBoundingBox().getMaxY() * 0.75));
    m_instance->addChild(m_enemySpecial);
    m_enemySpecial->setVisible(false); //hidden for animation
    */

    //Monster Sprite number 2
    m_enemyCard = Sprite::create(sprite->FirstChildElement("spriteList")->FirstChildElement("animation")->FirstChildElement("stand")->GetText());
    m_enemyCard->setScale(m_Mag * 1.5);
    m_enemyCard->setPosition(Vec2((m_visibleSize.width / 6) * 4.5, m_visibleSize.height /2));
    m_instance->addChild(m_enemyCard);

}
Пример #2
0
void InGameLayer::MenuBombCallback()
{
	SimpleAudioEngine::getInstance()->playEffect("sound/use_bomb.mp3");
	cleanAllEnemys();
	if(bombNum>0)
		bombNum--;

	auto label = static_cast<Label*>(this->getChildByTag(GameSceneNodeTagNumLabel));
	auto menu = static_cast<Menu*>(this->getChildByTag(GameSceneNodeTagMenuBomb));

	if (bombNum == 0)
	{
		label->setVisible(false);
		menu->setVisible(false);
	}
	else
	{
		label->setString(__String::createWithFormat("x%d",bombNum)->getCString());
	}
	score += 100;
	scoreLabel->setString(__String::createWithFormat("%d",score)->getCString());
	UserDefault *defaults = UserDefault::getInstance();
	int highScore = defaults->getIntegerForKey("highscore_key");    
	if (highScore < score) {
		highScore = score;
		defaults->setIntegerForKey("highscore_key", highScore);
	}
	__String *text = __String::createWithFormat("%i", highScore);

	auto lblScoreOfHigh = static_cast<Label*>(this->getChildByTag(GameSceneNodelblHighScore));
	lblScoreOfHigh->setString(text->getCString());
}
Пример #3
0
void BBHandleLayer::initData()
{
    m_visibleSize = Director::getInstance()->getVisibleSize();
    
    m_blockLength = kBlockLength * BBGameDataManager::getInstance()->getScreenScale();
    
    m_row = 5;
    m_col = 4;
    
    m_countDown = 2;
    
    m_blockArr = Array::create();
    m_blockArr->retain();
    
    m_isReady = false;
    m_showTips = false;
    m_moves = 0;
    m_over = false;
    
    m_mixTimes = 100;
    m_blockAnimOver = true;
    m_idleBlockLastDirection = 0;
    m_curIndex = m_row * m_col + 1;
    
    UserDefault *ud = UserDefault::getInstance();
    if (ud->getBoolForKey("hasLocalData")) {
        m_moves = ud->getIntegerForKey("moves");
    }
}
Пример #4
0
void SettingsDialog::onPressMusic(cocos2d::Ref *sender, cocos2d::extension::Control::EventType pControlEvent)
{
	if (pControlEvent == Control::EventType::TOUCH_UP_INSIDE)
	{
        UserDefault *ud = UserDefault::getInstance();
        bool value = ud->getBoolForKey("music_enabled", true);
        ud->setBoolForKey("music_enabled", !value);
        
        if (value)
        {
            _checkBoxMusic->removeAllChildren();
            CocosDenshion::SimpleAudioEngine::getInstance()->stopBackgroundMusic(false);
        }
        else
        {
            Label *l = Label::create();
            l->setString("X");
            l->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
            
            _checkBoxMusic->addChild(l);

            CocosDenshion::SimpleAudioEngine::getInstance()->playBackgroundMusic("playing.mp3", true);
        }
        
        ud->flush();
	}
}
Пример #5
0
const std::string CCNative::getDeviceID(void)
{
#define UDID_KEY "__UDID_KEY__"
	std::string udid;
	UserDefault* userDefault = UserDefault::getInstance();
	if( NULL != userDefault )
	{
		udid = userDefault->getStringForKey( UDID_KEY );
	}
	if( udid.size() == 0 )
	{   
		//GUID uuid; 
		//CoCreateGuid(&uuid); 
		//// Spit the address out 
		//char mac_addr[18]; 
		//sprintf(mac_addr,"%02X:%02X:%02X:%02X:%02X:%02X", 
		//uuid.Data4[2],uuid.Data4[3],uuid.Data4[4], 
		//uuid.Data4[5],uuid.Data4[6],uuid.Data4[7]); 
		udid = GetNetBiosMacAddresses();
		if( userDefault )
		{
			userDefault->setStringForKey(UDID_KEY, udid);
            userDefault->flush();
		}
	}
	return udid;
}
Пример #6
0
int StageManager::allCheck(int id) {
	//id = 0 BRUE, id = 1 RED
	int brue, red;
	UserDefault* userdef = UserDefault::getInstance();
	brue = 0, red = 0;
	//BRUE
	if (id == 0) {
		for (int i = 0; i < m_Container.size(); ++i) {
			if (m_Container.at(i)->getColor() == Color3B::BLUE) {
				 ++brue;
				 userdef->setIntegerForKey("blue", brue);
			}
		}
		return brue;
	}
	//RED
	if (id == 1) {
		for (int i = 0; i < m_Container.size(); ++i) {
			if (m_Container.at(i)->getColor() == Color3B::RED) {
				++red;
				userdef->setIntegerForKey("red", red);
			}
		}
		return red;
	}
}
Пример #7
0
NS_CC_EXTRA_BEGIN
const std::string CCNative::getDeviceID(void)
{
#define UDID_KEY "__UDID_KEY__"
	std::string udid;
	UserDefault* userDefault = UserDefault::getInstance();
	if( NULL != userDefault )
	{
		udid = userDefault->getStringForKey( UDID_KEY );
	}
	if( udid.size() == 0 )
	{
		//GUID guid = {0};
		//char szGuid[128]={0};
		//CoCreateGuid(&guid);
		//sprintf(szGuid, "%08X%04X%04X%02X%02X%02X%02X%02X%02X%02X%02X", guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]);
		//udid = "aaaaaaaaaaaaaaaaaaaa";
		udid = Application::getInstance()->getMacAddress();
		/// xx:xx:xx:xx:xx
		///一共有16位
		///4个冒号
		std::string::iterator end_pos = std::remove(udid.begin(), udid.end(), ' ');
		udid.erase(end_pos, udid.end()); 
		if( userDefault && udid.size() >= 16 )
		{
			userDefault->setStringForKey(UDID_KEY, udid);
		}
	}
	return udid;
}
Пример #8
0
// テキストの設定
void resultText::textSelect()
{
    // スコアデータの取得
    UserDefault *userDef = UserDefault::getInstance();
    float tempScore = userDef->getIntegerForKey("Score", 0);
    
    int textRoot;
    score = tempScore;
    
    if (SCOREBORDER_1)
    {
        textRoot = 1;
    }
    else if (SCOREBORDER_2)
    {
        textRoot = 2;
    }
    else if (SCOREBORDER_3)
    {
        textRoot = 3;
    }
    else if (SCOREBORDER_4)
    {
        textRoot = 4;
    }
    else
    {
        textRoot = 5;
    }
    
    texts(textRoot);
}
Пример #9
0
int BBGameDataManager::getStar(int themeId, int levelId)
{
    UserDefault* ud = UserDefault::getInstance();
    // 更新星级
    __String *starkey = __String::createWithFormat("star_%d_%d", themeId, levelId);
    return ud->getIntegerForKey(starkey->getCString(), 0);
}
Пример #10
0
int BBGameDataManager::getBestTime(int themeId, int levelId)
{
    UserDefault* ud = UserDefault::getInstance();
    
    __String *bestkey = __String::createWithFormat("best_%d_%d", themeId, levelId);
    return ud->getIntegerForKey(bestkey->getCString(), 0);
}
Пример #11
0
void Picking::displayIcon()
{
    auto fileU = FileUtils::getInstance();
    auto fileContent = fileU->getStringFromFile("data/animData.xml");

    UserDefault* def = UserDefault::getInstance();
    int key = def->getIntegerForKey(SaveDataKey[n_DataKeyNum::eMonsterData01 + m_battleNum].c_str());

    doc.Parse(fileContent.c_str());
    fileContent = fileU->getStringFromFile("data/monsterData.xml");
    mData.Parse(fileContent.c_str());

    m_HP = atoi(mData.FirstChildElement()->FirstChildElement(MonsterNameData[key].c_str())->FirstChildElement("HP")->GetText());
    auto sprite = doc.FirstChildElement()->FirstChildElement(MonsterNameData[key].c_str());


    key = def->getIntegerForKey(SaveDataKey[n_DataKeyNum::eEnemyMonster01 + m_battleNum].c_str());
    m_enemyHP = atoi(mData.FirstChildElement()->FirstChildElement(MonsterNameData[key].c_str())->FirstChildElement("HP")->GetText());


    //cut image to fit inside frame
    m_iconSprite = Sprite::create(sprite->FirstChildElement("spriteList")->FirstChildElement("animation")->FirstChildElement("stand")->GetText());
    m_iconSprite->setScale(m_Mag * 1.5);
    m_iconSprite->setPosition(Vec2((m_visibleSize.width / 6) * 1.8, m_visibleSize.height / 2));

    m_instance->addChild(m_iconSprite);
}
Пример #12
0
void Ajustes::cambiarSonido(float positionX,bool fondo){
    float min = 0.0;
    float max = 0.0;
    if(!fondo){
        min = barraEfectos->getPositionX()-((barraEfectos->getContentSize().width*escala)/2);
        max = barraEfectos->getPositionX()+((barraEfectos->getContentSize().width*escala)/2);
    }else{
        min = barraMusica->getPositionX()-((barraMusica->getContentSize().width*escala)/2);
        max = barraMusica->getPositionX()+((barraMusica->getContentSize().width*escala)/2);
    }
    float maxOriginal = max-min;
    float valorOriginal = positionX-min;
    float porcentaje = (floorf((100*valorOriginal)/maxOriginal))/100;
    
    UserDefault *preferencias = UserDefault::getInstance();
    if(positionX>min&&positionX<max){
        if(!fondo){
            btEfectos->setPositionX(positionX);
            Configuracion::volumenEfectos = porcentaje;
            CocosDenshion::SimpleAudioEngine::getInstance()->setEffectsVolume(Configuracion::volumenEfectos);
            preferencias->setFloatForKey("volEfectos", porcentaje);
        }else{
            btMusica->setPositionX(positionX);
            Configuracion::volumenMusica = porcentaje;
            CocosDenshion::SimpleAudioEngine::getInstance()->setBackgroundMusicVolume(Configuracion::volumenMusica);
            preferencias->setFloatForKey("volMusica", porcentaje);
        }
    }
}
Пример #13
0
// on "init" you need to initialize your instance
bool GameOverScene::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }
    
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();

	auto backgroundSprite = Sprite::create("Background.png");
	backgroundSprite->setPosition(Point(visibleSize.width / 2 + origin.x, visibleSize.height / 2 + origin.y));

	this->addChild(backgroundSprite);

	auto retryItem = MenuItemImage::create("Retry Button.png", "Retry Button Clicked.png", CC_CALLBACK_1(GameOverScene::GoToGameScene, this));
	retryItem->setPosition(Point(visibleSize.width /2 + origin.x, visibleSize.height / 4 * 3));

	auto mainMenuItem = MenuItemImage::create("Menu Button.png", "Menu Button Clicked.png", CC_CALLBACK_1(GameOverScene::GoToMainMenuScene, this));
	mainMenuItem->setPosition(Point(visibleSize.width /2 + origin.x, visibleSize.height / 4 ));

	auto menu = Menu::create(retryItem, mainMenuItem, NULL);
	menu->setPosition(Point::ZERO);

	this->addChild(menu);

	UserDefault *def = UserDefault::getInstance();

	auto highScore = def->getIntegerForKey("HIGHSCORE", 0);

	if (score > highScore)
	{
		highScore = score;

		def->setIntegerForKey("HIGHSCORE", highScore);
	}

	def->flush();

	__String *tempScore = __String::createWithFormat("Current : %i", score);

	auto currentScore = LabelTTF::create(tempScore->getCString(), "fonts/Marker Felt.ttf", visibleSize.height * SCORE_FONT_SIZE);
	currentScore->setPosition(Point(visibleSize.width * 0.25 + origin.x, visibleSize.height /2 + origin.y ));

	this->addChild(currentScore);
	
	__String *temHighpScore = __String::createWithFormat("High : %i", highScore);

	auto highScoreLabel = LabelTTF::create(temHighpScore->getCString(), "fonts/Marker Felt.ttf", visibleSize.height * SCORE_FONT_SIZE);

	highScoreLabel->setColor(Color3B::YELLOW);
	highScoreLabel->setPosition(Point(visibleSize.width * 0.75 + origin.x, visibleSize.height / 2 + origin.y));

	this->addChild(highScoreLabel);

	return true;
}
Пример #14
0
void HighScoreManager::registerCurrentScore(int score)
{
    UserDefault* userDef = UserDefault::getInstance();
    if (score > userDef->getIntegerForKey(KEY_HIGHSCORE.c_str(), 0))
    {
        userDef->setIntegerForKey(KEY_HIGHSCORE.c_str(), score);
    }
}
Пример #15
0
void ThirdPartyHelper::showReviewAlertWhenOpenTime(int opentime){
    UserDefault *ud = UserDefault::getInstance();
    int cu = ud->getIntegerForKey(LHOPENTIME, 0);
    cu ++;
    ud->setIntegerForKey(LHOPENTIME, cu);
    if (cu == opentime) {
        ThirdPartyHelper::showReviewAlert();
    }
}
Пример #16
0
// テキストの表示
void resultText::displayText()
{
    // 保存データの読み込み
    UserDefault *userDef = UserDefault::getInstance();
    
    float angle = userDef->getFloatForKey("scoreAngle", 0);
    float resultAngle = angle;
    
    if ( resultAngle < 0 )
    {
        resultAngle = resultAngle * (-1);
    }
    
    float distance = userDef->getFloatForKey("scoreDistance", 0);
    float resultDistance = distance;
    
    // 角度表示
    Label *viewAngle = Label::createWithSystemFont("a", "Arial", 50);
    viewAngle->setPosition(WINSIZE.width/2, WINSIZE.height/1.2);
    addChild(viewAngle);
    
    viewAngle->setString(StringUtils::format("角度:%0.2f°", resultAngle));
    log("%0.2f°",resultAngle);
    
    // 距離表示
    Label *viewPixel = Label::createWithSystemFont("", "Arial", 50);
    viewPixel->setPosition(WINSIZE.width/2, WINSIZE.height/1.37);
    addChild(viewPixel);
    
    viewPixel->setString(StringUtils::format("背表紙のりまでの間隔:%0.2fピクセル", resultDistance));
    log("%0.2fピクセル", resultDistance);
    
    // 点数表示
    Label *viewScore = Label::createWithSystemFont("", "Arial", 50);
    viewScore->setPosition(WINSIZE.width/2, WINSIZE.height/1.6);
    addChild(viewScore);

    viewScore->setString(StringUtils::format("点数:%ld", score));
    
    // 評価文章表示
    Label *viewText1 = Label::createWithSystemFont(arrayText[0], "Arial", 27);
    viewText1->setPosition(WINSIZE.width/2, 300);
    addChild(viewText1);

    Label *viewText2 = Label::createWithSystemFont(arrayText[1], "Arial", 27);
    viewText2->setPosition(WINSIZE.width/2, 250);
    addChild(viewText2);
    
    Label *viewText3 = Label::createWithSystemFont(arrayText[2], "Arial", 27);
    viewText3->setPosition(WINSIZE.width/2, 200);
    addChild(viewText3);
    
    viewText1->setString(StringUtils::format("プロジェクトマネージャー...%s", arrayText[0].c_str()));
    viewText2->setString(StringUtils::format("慇懃無礼な商人...%s", arrayText[1].c_str()));
    viewText3->setString(StringUtils::format("C...%s", arrayText[2].c_str()));
    log("ラベル配置");
}
Пример #17
0
void PlaySceneOne::onEnterTransitionDidFinish()
{
	Layer::onEnterTransitionDidFinish();
	log("GamePlayLayer onEnterTransitionDidFinish");
	UserDefault *defaults = UserDefault::getInstance();
	if (defaults->getBoolForKey(MUSIC_KEY)) {
		SimpleAudioEngine::getInstance()->playBackgroundMusic(bg_music_2, true);
	}
}
Пример #18
0
void NegiSprite::setSprite()
{
    this->setPosition(Vec2(WINSIZE.width/2, WINSIZE.height/2));
    
    float setLine = 3.0;
    
    UserDefault *userDef = UserDefault::getInstance();
    userDef->setFloatForKey("SetLine", setLine);
    userDef->flush();
}
Пример #19
0
void SettingLayer::menuSoundToggleCallback(Ref* pSender)
{
	UserDefault *defaults  = UserDefault::getInstance();
	if (defaults->getBoolForKey(SOUND_KEY)) {
		defaults->setBoolForKey(SOUND_KEY, false);
	} else {
		defaults->setBoolForKey(SOUND_KEY, true);
		SimpleAudioEngine::getInstance()->playEffect(sound_1);
	}
}
Пример #20
0
void SettingLayer::menuMusicToggleCallback(Ref* pSender)
{
	UserDefault *defaults  = UserDefault::getInstance();
	if (defaults->getBoolForKey(MUSIC_KEY)) {
		defaults->setBoolForKey(MUSIC_KEY, false);
		SimpleAudioEngine::getInstance()->stopBackgroundMusic();
	} else {
		defaults->setBoolForKey(MUSIC_KEY, true);
		SimpleAudioEngine::getInstance()->playBackgroundMusic(bg_music_2, true);
	}
}
Пример #21
0
void Developer::menuSoundCallback( Ref *pSender )
{
	auto soundToggleMenuItem = (MenuItemToggle*)pSender;   
  
    UserDefault *defaults  = UserDefault::getInstance();  
	if (defaults->getBoolForKey(SOUND_KEY)) {                                      
        defaults->setBoolForKey(SOUND_KEY, false);  
    } 
	else {  
        defaults->setBoolForKey(SOUND_KEY, true);   
    }
}
Пример #22
0
void BookSprite::setSprite()
{
    Size visibleSize = WINSIZE;
    Vec2 origin = Director::getInstance()->getVisibleOrigin();

    this->setPosition(Vec2(WINSIZE.width/1.4, WINSIZE.height/2));
    
    float setLine = 2.2;
    
    UserDefault *userDef = UserDefault::getInstance();
    userDef->setFloatForKey("SetLine", setLine);
    userDef->flush();
}
Пример #23
0
void Developer::menuMusicCallback( Ref *pSender )
{
	auto musicToggleMenuItem = (MenuItemToggle*)pSender;   
  
    UserDefault *defaults  = UserDefault::getInstance();  
    if (defaults->getBoolForKey(MUSIC_KEY)) {                                      
        defaults->setBoolForKey(MUSIC_KEY, false);  
        SimpleAudioEngine::getInstance()->stopBackgroundMusic();  
    } 
	else {  
        defaults->setBoolForKey(MUSIC_KEY, true);  
        SimpleAudioEngine::getInstance()->playBackgroundMusic("music_mainScene.wav");  
    }                                          
}
bool GameOverScene::init()	{
    if(!Layer::init())	{
        return false;
    }

    auto visibleSize = Director::getInstance()->getVisibleSize();
    auto origin = Director::getInstance()->getVisibleOrigin();

    UserDefault* userScore = UserDefault::getInstance();
    if(score >= userScore->getIntegerForKey( "highscore" ))	{
        userScore->setIntegerForKey( "highscore", score );
    }
    userScore->flush();

    //create background for game over scene
    auto background = Sprite::create("FlappyResources/Background.png");
    background->setPosition(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2);
    this->addChild(background);

    //create retry item
    auto retry = MenuItemImage::create( "FlappyResources/Retry_Button.png", "FlappyResources/Retry_Button_Clicked.png", CC_CALLBACK_1(GameOverScene::goToGameScene, this) );
    retry->setPosition( origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2 );

    //create quit item
    auto quit = MenuItemImage::create( "FlappyResources/Menu_Button.png", "FlappyResources/Menu_Button_Clicked.png", CC_CALLBACK_1(GameOverScene::goToMainMenuScene, this) );
    quit->setPosition( origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2 - quit->getContentSize().height * 2);

    //create menu
    auto menu = Menu::create( retry, quit, NULL );
    menu->setPosition( Vec2(0, 0) );

    //create label score
    auto stringScore = __String::createWithFormat( "Your score: %d", score );
    auto labelScore = LabelTTF::create( stringScore->getCString(), "fonts/Marker Belt.ttf", 50 );
    labelScore->setPosition( origin.x + labelScore->getContentSize().width, origin.y + visibleSize.height / 2 + labelScore->getContentSize().height * 4 );
    labelScore->setFontFillColor( Color3B::YELLOW );

    //create label display best score
    auto stringBestScore = __String::createWithFormat( "High score: %d", userScore->getIntegerForKey( "highscore" ) );
    auto labelHighScore = LabelTTF::create( stringBestScore->getCString(), "fonts/Marker Belt.ttf", 50 );
    labelHighScore->setPosition( origin.x + labelScore->getContentSize().width + visibleSize.width / 2, origin.y + visibleSize.height / 2 + labelHighScore->getContentSize().height * 4);
    labelHighScore->setFontFillColor( Color3B::RED );

    this->addChild( menu );
    this->addChild( labelScore );
    this->addChild( labelHighScore );

    return true;
}
Пример #25
0
void TestGameCenter::doAction(int tag) {
    switch (tag) {
        case TAG_GC_LOGIN: {
            //    std::function<void(int, std::string&)> callback = std::bind(&TestGameCenter::onUserCallback, this, std::placeholders::_1, std::placeholders::_2);
            //use cocos utils
            std::function<void(int, std::string&)> callback = CC_CALLBACK_2(TestGameCenter::onUserCallback, this);
            
            
            if (_protocolGameCenterUser->isLoggedIn()) {
                _resultInfo->setString("GameCenter: log in already.");
            } else {
                _protocolGameCenterUser->login(callback);
            }
        }
            break;
        case TAG_GC_LOGOUT: {
            std::function<void(int, std::string&)> callback = CC_CALLBACK_2(TestGameCenter::onUserCallback, this);
            _protocolGameCenterUser->logout(callback);
            break;
        }
        case TAG_GC_SHOW_LEADERBOARDS: {
            _protocolGameCenterSocial->showLeaderboards();
            break;
        }
        case TAG_GC_SHOW_ACHIEVEMENTS: {
            _protocolGameCenterSocial->showAchievements();
            break;
        }
        case TAG_GC_SUBMIT_SCORE: {
            UserDefault* userDefault = UserDefault::getInstance();
            int score = userDefault->getIntegerForKey("high-score", 1000) + 1;
            _protocolGameCenterSocial->submitScore(GAME_CENTER_LEADERBOARD_KEY_IOS_EASY, score, CC_CALLBACK_2(TestGameCenter::onSocialCallback, this));
            _resultInfo->setString(StringUtils::format("Submitting new high score: %d", score));
            break;
        }
        case TAG_GC_UNLOCK_ACHIEVEMENT: {
            _protocolGameCenterSocial->unlockAchievement(GAME_CENTER_ACHIEVEMENT_KEY_IOS_PRIME);
            _resultInfo->setString("Unlocking Achievement PRIME");
            break;
        }
        case TAG_GC_RESET_ACHIEVEMENTS: {
            _resultInfo->setString("Resetting all achievements...");
            _protocolGameCenterSocial->resetAchievements(CC_CALLBACK_2(TestGameCenter::onSocialCallback, this));
            break;
        }
        default:
            break;
    }
}
Пример #26
0
//ハイスコア記録・表示
void GameScene::saveHighScore()
{
    UserDefault* userDefault = UserDefault::getInstance();
    
    //ハイスコアを取得する
    int oldHighScore = userDefault->getIntegerForKey(KEY_HIGHSCORE,0);
    if(oldHighScore < m_score)
    {
        //ハイスコアを保存する
        userDefault->setIntegerForKey(KEY_HIGHSCORE, m_score);
        userDefault->flush();
        
        //ハイスコアを表示する
        showHighScoreLabel();
    }
}
Пример #27
0
void Result::pushScore(cocos2d::Ref *pSender){
    UserDefault *userDef = UserDefault::getInstance();
    
    
    int tempScore = userDef->getIntegerForKey("temp");
    std::string str = StringUtils::toString(tempScore);
    char *cstr = new char[str.length() + 1];
    strcpy(cstr, str.c_str());
    
    //    ScoreCenter::postScore("com.com.jugjug_scoreboard1", "30");
    #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    ScoreCenter::postScore("com.com.jugjug_scoreboard1",cstr);
    ScoreCenter::showRanking("com.com.jugjug_scoreboard1");
#endif
    
    delete [] cstr;
}
Пример #28
0
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    auto director = Director::getInstance();
    auto glview = director->getOpenGLView();
    if(!glview) {
        glview = GLView::create("My Game");
        director->setOpenGLView(glview);
    }
    
    auto frameSize = glview->getFrameSize();
    std::vector<std::string> searchPaths;
    if ((int)frameSize.width == 1536) {
        log("hdr");
        searchPaths.push_back("hdr");
        BBGameDataManager::getInstance()->setScreenScale(2);
    }else{
        log("hd");
        searchPaths.push_back("hd");
    }
    
    FileUtils::getInstance()->setSearchPaths(searchPaths);
    // turn on display FPS
    director->setDisplayStats(false);

    // set FPS. the default value is 1.0/60 if you don't call this
    director->setAnimationInterval(1.0 / 60);
    
    GameCenterApi::getInstance()->authenticateLocalUser();
    
    // Umeng
    MobClickCpp::startWithAppkey("5347fa3f56240b0b0f001049");
//    MobClickCpp::setLogEnabled(true);
    
    // create a scene. it's an autorelease object
    UserDefault* ud = UserDefault::getInstance();
    if (ud->getBoolForKey("notNewUser")) {
        director->runWithScene(BBGameScene::createScene());
    } else {
        director->runWithScene(BBWelcomeScene::createScene());
    }

    return true;
}
Пример #29
0
/*--------------------------/
 Yesボタン生成
 /--------------------------*/
void StageSelectActionLayer::buttonYes(cocos2d::Layer* layer,Menu* menu,int tag){
    
    auto buttonYes = MenuItemImage::create("Texture/GamePlay/GameScene/StageSelect/StageSelect_Yes.png",
                                           "Texture/GamePlay/GameScene/StageSelect/StageSelect_Yes.png",
                                           [ = ](Ref* sender)
                                           {
											   UserDefault* useDef = UserDefault::getInstance();
                                               useDef->setIntegerForKey("selectStage",tag);
											   useDef->setIntegerForKey("selectGimmick", tag);
                                               useDef->flush();
                                               
                                               auto nextScene = SceneCreator::createPhysicsScene(GameMainScene::create(), Vect(0, -9.8f), 5.0f);
                                               auto scene	= TransitionFade::create( 1.5f, nextScene, Color3B::BLACK );
                                               auto dir = Director::getInstance();
                                               dir->replaceScene(scene);
                                           });
    buttonYes->setPosition(400,300);
    buttonYes->setScale(1.2f);
    menu->addChild(buttonYes);
    
}
Пример #30
0
void GeneralUtils::setControllerType(ControllerType controllerType)
{
    int controllerTypeInt = 0;
    
    if (controllerType == E_CONTROLLER_TOUCH)
    {
        controllerTypeInt = 1;
    }
    else if (controllerType == E_CONTROLLER_TILT)
    {
        controllerTypeInt = 2;
    }
    else
    {
        return;
    }
    
    UserDefault *ud = UserDefault::getInstance();
    
    ud->setIntegerForKey("control_type", controllerTypeInt);
    ud->flush();
}