// time label GameTimeLabel::GameTimeLabel(int _min, int _sec) { switch(Settings::getInstance()->theme) { case SettingsThemeHacker: fontName = std::string("FontCourierNew16"); font = IGResourceManager::getInstance()->getFont(fontName); set(IGPoint(240,15), IGRect(180,30)); setColor(107,247,100,255); break; case SettingsThemeDetective: fontName = std::string("FontCourierNew14"); font = IGResourceManager::getInstance()->getFont(fontName); set(IGPoint(400,15), IGRect(100,30)); setColor(0,0,0,196); break; case SettingsThemeEspionage: fontName = std::string("FontCourierNew18"); font = IGResourceManager::getInstance()->getFont(fontName); set(IGPoint(290,18), IGRect(120,24)); setColor(72,72,72,196); break; } z = 2; tag = SceneGameTagTimeLabel; // time min = _min; sec = _sec; updateString(); // start start = s3eTimerGetMs(); stop = false; }
void IGSprite::changeImage(const char *resource) { if(image != NULL) IGResourceManager::getInstance()->freeImage(imageName); imageName = std::string(resource); image = IGResourceManager::getInstance()->getImage(imageName); this->set(position, IGRect(image->GetWidth(), image->GetHeight())); }
IGSprite::IGSprite(const char *resource, IGPoint _position, int _z, int _tag) { imageName = std::string(resource); image = IGResourceManager::getInstance()->getImage(imageName); this->set(_position, IGRect(image->GetWidth(), image->GetHeight())); z = _z; tag = _tag; this->setOpacity(255); }
IGSprite::IGSprite() { image = NULL; position = IGPoint(); size = IGRect(); z = 0; tag = 0; this->setOpacity(255); }
IGSprite::IGSprite(const IGSprite& s) { imageName = s.imageName; image = s.image; position = IGPoint(s.position); size = IGRect(s.size); z = s.z; tag = s.tag; this->setOpacity(255); }
// error continue button GameMenuButtonErrorContinue::GameMenuButtonErrorContinue() { imageNormalName = std::string("game_menu_error_continue"); imageNormal = IGResourceManager::getInstance()->getImage(imageNormalName); imageSelectedName = std::string("game_menu_error_continue2"); imageSelected = IGResourceManager::getInstance()->getImage(imageSelectedName); image = imageNormal; this->set(IGPoint(160,332)); touchSize = IGRect(320,50); z = 7; tag = GameMenuTagErrorContinue; }
// back button LeadersboardButtonBack::LeadersboardButtonBack() { imageNormalName = std::string("achievements_back"); imageNormal = IGResourceManager::getInstance()->getImage(imageNormalName); imageSelectedName = std::string("achievements_back2"); imageSelected = IGResourceManager::getInstance()->getImage(imageSelectedName); image = imageNormal; this->set(IGPoint(55,452)); touchSize = IGRect(111,56); z = 2; tag = 0; }
// menu button LeadersboardButtonMenu::LeadersboardButtonMenu() { imageNormalName = std::string("leadersboard_menu"); imageNormal = IGResourceManager::getInstance()->getImage(imageNormalName); imageSelectedName = std::string("leadersboard_menu2"); imageSelected = IGResourceManager::getInstance()->getImage(imageSelectedName); image = imageNormal; this->set(IGPoint(160,452)); touchSize = IGRect(98,56); z = 2; tag = 0; }
// reset button OptionsButtonReset::OptionsButtonReset() { imageNormalName = std::string("options_reset"); imageNormal = IGResourceManager::getInstance()->getImage(imageNormalName); imageSelectedName = std::string("options_reset2"); imageSelected = IGResourceManager::getInstance()->getImage(imageSelectedName); image = imageNormal; this->set(IGPoint(160,376)); touchSize = IGRect(320,56); z = 2; tag = 0; }
// reset cancel button OptionsButtonResetCancel::OptionsButtonResetCancel() { imageNormalName = std::string("options_reset_confirm_cancel"); imageNormal = IGResourceManager::getInstance()->getImage(imageNormalName); imageSelectedName = std::string("options_reset_confirm_cancel2"); imageSelected = IGResourceManager::getInstance()->getImage(imageSelectedName); image = imageNormal; this->set(IGPoint(235,260)); touchSize = IGRect(150,56); z = 7; tag = OptionsTagResetButtonCancel; }
// no button NagButtonNo::NagButtonNo() { imageNormalName = std::string("nag_no"); imageNormal = IGResourceManager::getInstance()->getImage(imageNormalName); imageSelectedName = std::string("nag_no2"); imageSelected = IGResourceManager::getInstance()->getImage(imageSelectedName); image = imageNormal; this->set(IGPoint(160,396)); touchSize = IGRect(320,56); z = 2; tag = 0; }
// next button LeadersboardButtonNext::LeadersboardButtonNext() { imageNormalName = std::string("leadersboard_next"); imageNormal = IGResourceManager::getInstance()->getImage(imageNormalName); imageSelectedName = std::string("leadersboard_next2"); imageSelected = IGResourceManager::getInstance()->getImage(imageSelectedName); image = imageNormal; this->set(IGPoint(265,452)); touchSize = IGRect(111,56); z = 2; tag = 0; }
// next button GameMenuButtonNext::GameMenuButtonNext() { imageNormalName = std::string("game_menu_next"); imageNormal = IGResourceManager::getInstance()->getImage(imageNormalName); imageSelectedName = std::string("game_menu_next2"); imageSelected = IGResourceManager::getInstance()->getImage(imageSelectedName); image = imageNormal; this->set(IGPoint(160,296)); touchSize = IGRect(320,50); z = 2; tag = 0; }
// back button OptionsButtonBack::OptionsButtonBack() { if(GameData::getInstance()->optionsReturnsToGame) { imageNormalName = std::string("options_back_game"); imageSelectedName = std::string("options_back_game2"); } else { imageNormalName = std::string("options_back_menu"); imageSelectedName = std::string("options_back_menu2"); } imageNormal = IGResourceManager::getInstance()->getImage(imageNormalName); imageSelected = IGResourceManager::getInstance()->getImage(imageSelectedName); image = imageNormal; this->set(IGPoint(160,452)); touchSize = IGRect(320,56); z = 2; tag = 0; }
// alphabet letter GameAlphabetLetter::GameAlphabetLetter(int _alphabetLetter, bool used) { alphabetLetter = _alphabetLetter; char bufferTheme[50], bufferLetter[5], buffer[200]; // figure out the theme switch(Settings::getInstance()->theme) { case SettingsThemeHacker: sprintf(bufferTheme, "Hacker"); break; case SettingsThemeDetective: sprintf(bufferTheme, "Detective"); break; case SettingsThemeEspionage: sprintf(bufferTheme, "Espionage"); break; } // figure out the letter if(alphabetLetter == GameAlphabetDEL) sprintf(bufferLetter, "DEL"); else if(alphabetLetter == GameAlphabetESC) sprintf(bufferLetter, "ESC"); else sprintf(bufferLetter, "%c", alphabetLetter+'A'); // figure out the names if(used) { sprintf(buffer, "Game%sAlphabetUsed%s", bufferTheme, bufferLetter); imageNormalName = std::string(buffer); } else { sprintf(buffer, "Game%sAlphabet%s", bufferTheme, bufferLetter); imageNormalName = std::string(buffer); } sprintf(buffer, "Game%sAlphabetPressed%s", bufferTheme, bufferLetter); imageSelectedName = std::string(buffer); imageNormal = IGResourceManager::getInstance()->getImage(imageNormalName); imageSelected = IGResourceManager::getInstance()->getImage(imageSelectedName); image = imageNormal; // init the rest of the button int x = (alphabetLetter % 7); int y = (int)(alphabetLetter / 7); this->set(IGPoint((float)(90+(50*x)),(float)(88+(50*y)))); touchSize = IGRect(55,55); // make the buttons a little bigger than they actually are -- seems more responsive // touchSize = IGRect(50,50); z = 6; tag = SceneGameTagAlphabetLetters+alphabetLetter; // wait a couple frames before counting touches touchCount = 0; }
// ciphertext label GameCiphertextLabel::GameCiphertextLabel(char c, int row, int col, int _tag) { fontName = std::string("FontCourierNew18"); font = IGResourceManager::getInstance()->getFont(fontName); //set(IGPoint((float)(41+(col*20)),(float)(64.5+(row*46))), IGRect(20, 23)); set(IGPoint((float)(19+(col*26)),(float)(64.5+(row*46))), IGRect(26, 23)); switch(Settings::getInstance()->theme) { case SettingsThemeHacker: setColor(147,226,134,255); break; case SettingsThemeDetective: setColor(65,109,182,255); break; case SettingsThemeEspionage: setColor(186,36,36,255); break; } setString(std::string(1, c)); z = 2; tag = _tag; }
// menu button GameButtonMenu::GameButtonMenu() { switch(Settings::getInstance()->theme) { case SettingsThemeHacker: imageNormalName = std::string("GameHackerButtonMenu"); imageSelectedName = std::string("GameHackerButtonMenu2"); break; case SettingsThemeDetective: imageNormalName = std::string("GameDetectiveButtonMenu"); imageSelectedName = std::string("GameDetectiveButtonMenu2"); break; case SettingsThemeEspionage: imageNormalName = std::string("GameEspionageButtonMenu"); imageSelectedName = std::string("GameEspionageButtonMenu2"); break; } imageNormal = IGResourceManager::getInstance()->getImage(imageNormalName); imageSelected = IGResourceManager::getInstance()->getImage(imageSelectedName); image = imageNormal; this->set(IGPoint(382.5,290)); touchSize = IGRect(141,60); z = 1; tag = SceneGameTagButtonMenu; }
// complete menu button GameCompleteButtonMenu::GameCompleteButtonMenu() { switch(Settings::getInstance()->theme) { case SettingsThemeHacker: imageNormalName = std::string("GameHackerCompleteMenu"); imageSelectedName = std::string("GameHackerCompleteMenu2"); break; case SettingsThemeDetective: imageNormalName = std::string("GameDetectiveCompleteMenu"); imageSelectedName = std::string("GameDetectiveCompleteMenu2"); break; case SettingsThemeEspionage: imageNormalName = std::string("GameEspionageCompleteMenu"); imageSelectedName = std::string("GameEspionageCompleteMenu2"); break; } imageNormal = IGResourceManager::getInstance()->getImage(imageNormalName); imageSelected = IGResourceManager::getInstance()->getImage(imageSelectedName); image = imageNormal; this->set(IGPoint(240,280)); touchSize = IGRect(340,40); z = 1; tag = 0; }
// empty slot sprite GameSlot::GameSlot(int _row, int _col, int _tag) { row = _row; col = _col; image = NULL; switch(Settings::getInstance()->theme) { case SettingsThemeHacker: imageName = std::string("GameHackerSlot"); break; case SettingsThemeDetective: imageName = std::string("GameDetectiveSlot"); break; case SettingsThemeEspionage: imageName = std::string("GameEspionageSlot"); break; } image = IGResourceManager::getInstance()->getImage(imageName); //set(IGPoint((float)(41+(col*20)),(float)(41.5+(row*46))), IGRect(20, 23)); set(IGPoint((float)(19+(col*26)),(float)(41.5+(row*46))), IGRect(26, 23)); // setting it slightly bigger than it was before z = 1; tag = 0; setOpacity(255); tag = _tag; }
void SceneGame::updatePhrase() { unsigned int i,j; // create the answer key from the inverse strcpy(answerKey, "__________________________"); for(i=0; i<26; i++) { for(j=0; j<26; j++) { if(inverseAnswerKey[j] == ('A'+i)) answerKey[i] = j+'A'; } } // update the plaintext label for(i=0; i<strlen(plaintext); i++) { // if it's a letter decrypt it with answerKey if(ciphertext[i] >= 'A' && ciphertext[i] <= 'Z') { GamePlaintextLabel* label = (GamePlaintextLabel*)this->getChildByTag(SceneGameTagPlaintextLabels+i); int index = ciphertext[i]-'A'; if(inverseAnswerKey[index] != '_') label->setString(std::string(1,inverseAnswerKey[index])); else label->setString(std::string(" ")); } } /*// check for duplicates int count[26] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; bool duplicates = false; // set the color of each plaintext label to normal color for(i=0; i<strlen(plaintext); i++) { if(plaintext[i] >= 'A' && plaintext[i] <= 'Z') { GamePlaintextLabel* label = (GamePlaintextLabel*)this->getChildByTag(SceneGameTagPlaintextLabels+i); label->setColorNormal(); } } // count how many of each letter is used in the answer key for(i=0; i<26; i++) { if(inverseAnswerKey[i] != '_') { count[inverseAnswerKey[i]-'A']++; if(count[inverseAnswerKey[i]-'A'] > 1) duplicates = true; } } // change duplicate letters to duplicate color if(duplicates) { for(i=0; i<26; i++) { if(count[i] > 1) { for(j=0; j<strlen(plaintext); j++) { if(inverseAnswerKey[ciphertext[j]-'A'] == i+'A') { GamePlaintextLabel* label = (GamePlaintextLabel*)this->getChildByTag(SceneGameTagPlaintextLabels+j); label->setColorDuplicate(); } } } } }*/ // update the key label IGLabel* labelAnswerKeyLetters = (IGLabel*)this->getChildByTag(SceneGameTagLabelAnswerKeyLetters); labelAnswerKeyLetters->setString(std::string(inverseAnswerKey)); // check for a win bool win = true; for(i=0; i<26; i++) { if(frequency[i] > 0) { if(inverseAnswerKey[i] != inverseKey[i]) win = false; } } if(win) { // stop the timer GameTimeLabel* timeLabel = (GameTimeLabel*)this->getChildByTag(SceneGameTagTimeLabel); if(timeLabel != NULL) timeLabel->stop = true; // remove the answer key this->removeChildByTag(SceneGameTagLabelAlphabet); this->removeChildByTag(SceneGameTagLabelAnswerKey); this->removeChildByTag(SceneGameTagLabelAlphabetLetters); this->removeChildByTag(SceneGameTagLabelAnswerKeyLetters); // remove the buttons this->removeChildByTag(SceneGameTagButtonNewPuzzle); this->removeChildByTag(SceneGameTagButtonHint); this->removeChildByTag(SceneGameTagButtonMenu); // remove the actual puzzle for(i=0; i<strlen(ciphertext); i++) { this->removeChildByTag(SceneGameTagSlots+i); this->removeChildByTag(SceneGameTagPlaintextLabels+i); this->removeChildByTag(SceneGameTagCiphertextLabels+i); } // add the phrase IGLabel* phraseLabel = new IGLabel("FontCourierNew18", std::string(plaintext), IGPoint(240,122), IGRect(380,184), 1); switch(Settings::getInstance()->theme) { case SettingsThemeHacker: phraseLabel->setColor(255, 255, 255, 255); break; case SettingsThemeDetective: case SettingsThemeEspionage: phraseLabel->setColor(0, 0, 0, 255); break; } this->addChild(phraseLabel); // add complete buttons GameCompleteButtonPlayAgain* buttonCompletePlayAgain = new GameCompleteButtonPlayAgain(); GameCompleteButtonMenu* buttonCompleteMenu = new GameCompleteButtonMenu(); this->addChild(buttonCompletePlayAgain); this->addChild(buttonCompleteMenu); // start a new game this->newGame(); } }
void IGSprite::set(IGPoint _position) { set(_position, IGRect(image->GetWidth(), image->GetHeight())); }
void SceneLeadersboard::updateLeadersboard() { int i; // start by getting rid of all the old achievements for(i=0; i<4*5; i++) // 4 element for each of 5 achivments on the page removeChildByTag(LeadersboardTagItems+i); // figure out what achievements need displaying int start = pageNumber*5; int end = start+5; if(end >= LEADERSBOARD_NUM) end = LEADERSBOARD_NUM; // display them int curTag = LeadersboardTagItems; int curItem = 0; for(i=start; i<end; i++) { LeadersboardScore a = Leadersboard::getInstance()->getLeadersboardScore(i); // row background IGSprite* spriteRowBackground = new IGSprite("achievements_row_background", IGPoint(160,116+68*curItem), 5, curTag); this->addChild(spriteRowBackground); curTag++; // name and description IGLabel* labelName = new IGLabel("font_gabriola_16b", a.name.c_str(), IGPoint(196,105+68*curItem), IGRect(232,34), 6, curTag); labelName->setColor(255,255,255,255); this->addChild(labelName); curTag++; const char *score = f_ssprintf("level %d (in %d seconds)", a.level, a.sec); IGLabel* labelDescription = new IGLabel("font_gabriola_14", score, IGPoint(196,127+68*curItem), IGRect(232,34), 6, curTag); labelDescription->setColor(196,207,226,255); this->addChild(labelDescription); curTag++; curItem++; } }
void SceneAchievements::updateAchievements() { int i; // start by getting rid of all the old achievements for(i=0; i<4*5; i++) // 4 element for each of 5 achivments on the page removeChildByTag(AchievementsTagItems+i); // figure out what achievements need displaying int start = pageNumber*5; int end = start+5; if(end >= ACHIEVEMENT_NUM) end = ACHIEVEMENT_NUM; // display them int curTag = AchievementsTagItems; int curItem = 0; for(i=start; i<end; i++) { Achievement a = Achievements::getInstance()->getAchievement(i); // row background IGSprite* spriteRowBackground = new IGSprite("achievements_row_background", IGPoint(160,116+68*curItem), 5, curTag); this->addChild(spriteRowBackground); curTag++; // name and description IGLabel* labelName = new IGLabel("font_gabriola_16b", a.name.c_str(), IGPoint(196,105+68*curItem), IGRect(232,34), 6, curTag); labelName->setColor(255,255,255,255); this->addChild(labelName); curTag++; IGLabel* labelDescription = new IGLabel("font_gabriola_14", a.description.c_str(), IGPoint(196,127+68*curItem), IGRect(232,34), 6, curTag); labelDescription->setColor(196,207,226,255); this->addChild(labelDescription); curTag++; // trophy if(a.achieved) { IGSprite* spriteTrophy = new IGSprite("achievements_trophy", IGPoint(44,116+68*curItem), 6, curTag); this->addChild(spriteTrophy); } else { IGSprite* spriteTrophy = new IGSprite("achievements_locked_trophy", IGPoint(44,116+68*curItem), 6, curTag); this->addChild(spriteTrophy); // dim everything out labelName->setOpacity(128); labelDescription->setOpacity(128); spriteTrophy->setOpacity(128); } curTag++; curItem++; } }
// game scene SceneGame::SceneGame() { IGScene::IGScene(); IGLog("SceneGame init"); unsigned int i, j; // load the game phraseId = 0; savedGameDB = new SQLite3Wrapper("savedGame.db"); loadGame(); // init physical keyboard array s3eKeys[0]=s3eKeyA; s3eKeys[1]=s3eKeyB; s3eKeys[2]=s3eKeyC; s3eKeys[3]=s3eKeyD; s3eKeys[4]=s3eKeyE; s3eKeys[5]=s3eKeyF; s3eKeys[6]=s3eKeyG; s3eKeys[7]=s3eKeyH; s3eKeys[8]=s3eKeyI; s3eKeys[9]=s3eKeyJ; s3eKeys[10]=s3eKeyK; s3eKeys[11]=s3eKeyL; s3eKeys[12]=s3eKeyM; s3eKeys[13]=s3eKeyN; s3eKeys[14]=s3eKeyO; s3eKeys[15]=s3eKeyP; s3eKeys[16]=s3eKeyQ; s3eKeys[17]=s3eKeyR; s3eKeys[18]=s3eKeyS; s3eKeys[19]=s3eKeyT; s3eKeys[20]=s3eKeyU; s3eKeys[21]=s3eKeyV; s3eKeys[22]=s3eKeyW; s3eKeys[23]=s3eKeyX; s3eKeys[24]=s3eKeyY; s3eKeys[25]=s3eKeyZ; // load resources, background image IGSprite* spriteBackground = NULL; switch(Settings::getInstance()->theme) { case SettingsThemeHacker: IwGetResManager()->LoadGroup("game_hacker.group"); spriteBackground = new IGSprite("GameHackerBackground", IGPoint(240,160), 0); break; case SettingsThemeDetective: IwGetResManager()->LoadGroup("game_detective.group"); spriteBackground = new IGSprite("GameDetectiveBackground", IGPoint(240,160), 0); break; case SettingsThemeEspionage: IwGetResManager()->LoadGroup("game_espionage.group"); spriteBackground = new IGSprite("GameEspionageBackground", IGPoint(240,160), 0); break; } this->addChild(spriteBackground); // buttons GameButtonNewPuzzle* buttonNewPuzzle = new GameButtonNewPuzzle(); GameButtonHint* buttonHint = new GameButtonHint(); GameButtonMenu* buttonMenu = new GameButtonMenu(); this->addChild(buttonNewPuzzle); this->addChild(buttonHint); this->addChild(buttonMenu); // time int sec = (int)(time%60); int min = (int)(time/60); GameTimeLabel* timeLabel = new GameTimeLabel(min,sec); this->addChild(timeLabel); // draw the phrase const unsigned int maxCols = 18; // used to be 21 const unsigned int maxRows = 4; int columnCount[4] = {0,0,0,0}; // count number of columns per row unsigned int col = 0; unsigned int row = 0; for(i=0; i<strlen(ciphertext); i++) { // if it's a space in the first column, skip this one while(col == 0 && ciphertext[i] == ' ') i++; // if it's a word, see if there's enough space in this line if(ciphertext[i] != ' ') { for(j=i+1; j<strlen(ciphertext); j++) { if(ciphertext[j] == ' ' || ciphertext[j] == '\0') break; } if(col + (j-i) >= maxCols) { col = 0; row++; } } // if it's a letter, draw empty box and an empty plaintext label if(ciphertext[i] >= 'A' && ciphertext[i] <= 'Z') { GameSlot* slot = new GameSlot(row, col, SceneGameTagSlots+i); GamePlaintextLabel* plaintextLabel = new GamePlaintextLabel(' ', row, col, SceneGameTagPlaintextLabels+i); this->addChild(slot); this->addChild(plaintextLabel); } // otherwise draw the character else { if(ciphertext[i] != ' ') { GamePlaintextLabel* plaintextLabel = new GamePlaintextLabel(ciphertext[i], row, col, SceneGameTagPlaintextLabels+i); this->addChild(plaintextLabel); } } // draw the ciphertext if(ciphertext[i] != ' ') { GameCiphertextLabel* ciphertextLabel = new GameCiphertextLabel(ciphertext[i], row, col, SceneGameTagCiphertextLabels+i); this->addChild(ciphertextLabel); } // count the columns columnCount[row]++; // increment the column col++; if(col == maxCols) { col = 0; row++; } } // center the text, total width=468, letter width=26 for(i=0; i<4; i++) { int width = columnCount[i]; int index = -1; for(j=0; j<=i; j++) index += columnCount[j]; if(ciphertext[index] == ' ') width--; centerOffset[i] = (468 - (width*26)) / 2; } row = 0; for(i=0; i<strlen(ciphertext); i++) { GameSlot* slot = (GameSlot*)this->getChildByTag(SceneGameTagSlots+i); if(slot != NULL) { row = slot->row; slot->position.x += centerOffset[row]; } GamePlaintextLabel* plaintextLabel = (GamePlaintextLabel*)this->getChildByTag(SceneGameTagPlaintextLabels+i); if(plaintextLabel != NULL) plaintextLabel->position.x += centerOffset[row]; GameCiphertextLabel* ciphertextLabel = (GameCiphertextLabel*)this->getChildByTag(SceneGameTagCiphertextLabels+i); if(ciphertextLabel != NULL) ciphertextLabel->position.x += centerOffset[row]; } // draw the key IGLabel* labelAlphabet = new IGLabel("FontFixedSys14", "alphabet: ", IGPoint(123,230), IGRect(90,20), 2, SceneGameTagLabelAlphabet); IGLabel* labelAnswerKey = new IGLabel("FontFixedSys14", " key: ", IGPoint(123,250), IGRect(90,20), 2, SceneGameTagLabelAnswerKey); IGLabel* labelAlphabetLetter = new IGLabel("FontFixedSys14", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", IGPoint(294,230), IGRect(234,20), 2, SceneGameTagLabelAlphabetLetters); IGLabel* labelAnswerKeyLetter = new IGLabel("FontFixedSys14", "__________________________", IGPoint(294,250), IGRect(234,20), 2, SceneGameTagLabelAnswerKeyLetters); switch(Settings::getInstance()->theme) { case SettingsThemeHacker: labelAnswerKey->setColor(140,140,140,255); labelAlphabet->setColor(140,140,140,255); labelAnswerKeyLetter->setColor(210,220,210,255); labelAlphabetLetter->setColor(210,220,210,255); break; case SettingsThemeDetective: case SettingsThemeEspionage: labelAnswerKey->setColor(80,80,80,255); labelAlphabet->setColor(80,80,80,255); labelAnswerKeyLetter->setColor(20,20,20,255); labelAlphabetLetter->setColor(20,20,20,255); break; break; } this->addChild(labelAnswerKey); this->addChild(labelAlphabet); this->addChild(labelAnswerKeyLetter); this->addChild(labelAlphabetLetter); // keyboard keyboardUp = false; // update the phrase updatePhrase(); }
// scene game menu SceneGameMenu::SceneGameMenu() : IGScene() { IGLog("SceneGameMenu init"); errorUp = false; // load the resources IwGetResManager()->LoadGroup("game_menu.group"); // the background IGSprite* spriteBackground = new IGSprite("background_forest_light", IGPoint(160,240), 0); this->addChild(spriteBackground); // header IGSprite* spriteHeader = new IGSprite("game_menu_header", IGPoint(160,60), 1); this->addChild(spriteHeader); // the menu items GameMenuButtonResume* buttonResume = new GameMenuButtonResume(); GameMenuButtonRestart* buttonRestart = new GameMenuButtonRestart(); GameMenuButtonNext* buttonNext = new GameMenuButtonNext(); GameMenuButtonOptions* buttonOptions = new GameMenuButtonOptions(); GameMenuButtonAbandon* buttonAbandon = new GameMenuButtonAbandon(); this->addChild(buttonResume); this->addChild(buttonRestart); this->addChild(buttonNext); this->addChild(buttonOptions); this->addChild(buttonAbandon); // game info IGSprite* spriteInfoBackground = new IGSprite("game_menu_info_background", IGPoint(160,145), 2); this->addChild(spriteInfoBackground); char buffer1[50]; char buffer2[100]; switch(GameData::getInstance()->stage) { case GameStageForest: sprintf(buffer1, "Forest"); break; case GameStageCaves: sprintf(buffer1, "Caves"); break; case GameStageBeach: sprintf(buffer1, "Beach"); break; case GameStageShip: sprintf(buffer1, "Pirate Ship"); break; } sprintf(buffer2, "%s * Level: %i", buffer1, GameData::getInstance()->level); IGLabel* labelInfo = new IGLabel("font_algerian_16", std::string(buffer2), IGPoint(160,145), IGRect(300,50), 3); labelInfo->setColor(147,213,18,255); this->addChild(labelInfo); }
void SceneGame::popUpKeyboard() { if(keyboardUp == false) { keyboardUp = true; // add black background IGSprite* keyboardBlack = new IGSprite("BackgroundBlack", IGPoint(240,160), 4, SceneGameTagKeyboardBlack); keyboardBlack->setOpacity(64); this->addChild(keyboardBlack); // display the selected letter IGSprite* selectedLetterBackground = new IGSprite("GameAlphabetSelectedLetterBackground", IGPoint(240,48), 5, SceneGameTagKeyboardLabelSelectedBackground); this->addChild(selectedLetterBackground); char buffer[200]; sprintf(buffer, "Selected Letter: %c", selectedChar); IGLabel* labelSelectedLetter = new IGLabel("FontCourierNew18", std::string(buffer), IGPoint(240,48), IGRect(480,30), 6, SceneGameTagKeyboardLabelSelectedLetter); labelSelectedLetter->setColor(255, 255, 255, 255); this->addChild(labelSelectedLetter); // add the keys for(int i=GameAlphabetA; i<=GameAlphabetESC; i++) { GameAlphabetLetter* letterButton = new GameAlphabetLetter(i, isLetterUsed(i)); this->addChild(letterButton); } } }
void IGSprite::set(IGPoint _position, IGRect _size) { position = IGPoint(_position); size = IGRect(_size); }