void MainMenu::Init() { Scene::Init(); // Create menu background int w = IwGxGetScreenWidth(); int h = IwGxGetScreenHeight(); if (w > h) { int temp = w; w = h; h = temp; } CSprite* background = new CSprite(); background->m_X = (float)w / 2; background->m_Y = (float)h / 2; background->SetImage(g_pResources->getMenuBG()); background->m_W = background->GetImage()->GetWidth(); background->m_H = background->GetImage()->GetHeight(); background->m_AnchorX = 0.5; background->m_AnchorY = 0.5; // Fit background to screen size background->m_ScaleX = (float)w / background->GetImage()->GetWidth(); background->m_ScaleY = (float)h / background->GetImage()->GetHeight(); AddChild(background); playButton = new CSprite(); playButton->SetImage(g_pResources->getPlayButton()); playButton->m_X = w / 2.0f; playButton->m_Y = h / 2.0f; playButton->m_W = playButton->GetImage()->GetWidth(); playButton->m_H = playButton->GetImage()->GetHeight(); playButton->m_AnchorX = 0.5f; playButton->m_AnchorY = 0.5f; playButton->m_ScaleX = (float)(w * 0.4) / playButton->GetImage()->GetWidth(); playButton->m_ScaleY = playButton->m_ScaleX; AddChild(playButton); // Create pause menu sprite (docked to top of screen) optionsSprite = new CSprite(); optionsSprite->SetImage(g_pResources->getSettingsButton()); optionsSprite->m_X = (int)IwGxGetDeviceWidth() * 0.9; optionsSprite->m_Y = (int)IwGxGetDeviceHeight() * 0.9; optionsSprite->m_W = optionsSprite->GetImage()->GetWidth(); optionsSprite->m_H = optionsSprite->GetImage()->GetHeight(); optionsSprite->m_AnchorX = 0.5; optionsSprite->m_ScaleX = (float)(IwGxGetDeviceWidth() * 0.13) / optionsSprite->GetImage()->GetWidth(); optionsSprite->m_ScaleY = optionsSprite->m_ScaleX; AddChild(optionsSprite); // Start menu music //Audio::PlayMusic("audio/frontend.mp3"); }
CIwTexture* Transitions2D::CaptureScreen() { int w = IwGxGetDeviceWidth(); int h = IwGxGetDeviceHeight(); int length = w * h * 4; uint8* buffer = new uint8[length]; glReadPixels(0, 0, w, h, 0x1908, 0x1401, buffer); uint8* buffer2 = new uint8[length]; int lineSize = w * 4; uint8* b1 = buffer; uint8* b2 = buffer2 + h * lineSize;; for(int y = h; y > 0; y--) { b2 -= lineSize; for(int x = w; x > 0; x--) { *b2++ = *b1++; *b2++ = *b1++; *b2++ = *b1++; *b2++ = *b1++; } b2 -= lineSize; } CIwTexture* texture = new CIwTexture; CIwImage& img = texture->GetImage(); img.SetFormat(CIwImage::ABGR_8888); img.SetWidth(w); img.SetHeight(h); img.SetBuffers(buffer2, length); //img.SaveBmp("screenshot.bmp"); texture->SetMipMapping(false); texture->Upload(); delete buffer; delete buffer2; return texture; }
void Game::Init() { //m_Angle = 90.0f; ScreenWidth = IwGxGetDeviceWidth(); ScreenHeight = IwGxGetDeviceHeight(); gameOverSprite = NULL; g_pResources->loadGame(); initUI(); pushBack = (ScreenHeight / 20); projectiles = new hadoken_vec[2]; projectileLines = new sprite_vec[2]; g_pExplosionManager = new ExplosionManager(); NewGame(); }
} if (m_EndTexture != NULL) { delete m_EndTexture; m_EndTexture = NULL; } printf("Transition Manager cleaned up\n"); } CIwTexture* TransitionManager::CaptureScreen() { IW_CALLSTACK("TransitionManager::CaptureScreen") int w = IwGxGetDeviceWidth(); int h = IwGxGetDeviceHeight(); int length = w * h * 4; uint8* buffer = new uint8[length]; //RGBA, //Unsigned byte glReadPixels(0, 0, w, h, 0x1908, 0x1401, buffer); uint8* buffer2 = new uint8[length]; int lineSize = w * 4; uint8* b1 = buffer; uint8* b2 = buffer2 + h * lineSize;; for(int y = h; y > 0; y--) { b2 -= lineSize; for(int x = w; x > 0; x--)