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(); }
m_StartTexture = NULL; } 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;
void Streamer::Update(float deltaTime, float alphaMul) { CNode::Update(deltaTime, alphaMul); if (g_pInput->m_Touched) { if(!touched) { touched = true; x = g_pInput->m_X; y = g_pInput->m_Y; } } // Detect screen tap if (!g_pInput->m_Touched && g_pInput->m_PrevTouched && sceneSwitchComplete) { if(playButton->HitTest(g_pInput->m_X, g_pInput->m_Y) && g_pInput->m_X > x - 20 && g_pInput->m_X < x + 20 && g_pInput->m_Y > y - 20 && g_pInput->m_Y < y + 20) { g_pInput->Reset(); playButton->m_X = IwGxGetScreenWidth() * 2.0; stopButton->m_X = IwGxGetScreenWidth() / 2.0; startStreaming(); } else if(stopButton->HitTest(g_pInput->m_X, g_pInput->m_Y) && g_pInput->m_X > x - 20 && g_pInput->m_X < x + 20 && g_pInput->m_Y > y - 20 && g_pInput->m_Y < y + 20) { g_pInput->Reset(); playButton->m_X = IwGxGetScreenWidth() / 2.0; stopButton->m_X = IwGxGetScreenWidth() * 2.0; pauseStreaming(); } if(facebook->HitTest(g_pInput->m_X, g_pInput->m_Y) && g_pInput->m_X > x - 20 && g_pInput->m_X < x + 20 && g_pInput->m_Y > y - 20 && g_pInput->m_Y < y + 20) { g_pInput->Reset(); s3eOSExecExecute("https://www.facebook.com/pages/UCCS-Radio/229529077104562", S3E_FALSE); } else if(twitter->HitTest(g_pInput->m_X, g_pInput->m_Y) && g_pInput->m_X > x - 20 && g_pInput->m_X < x + 20 && g_pInput->m_Y > y - 20 && g_pInput->m_Y < y + 20) { g_pInput->Reset(); s3eOSExecExecute("https://twitter.com/uccsonlineradio", S3E_FALSE); } if ((labelLeft->HitTest(g_pInput->m_X, g_pInput->m_Y) && g_pInput->m_X > x - 20 && g_pInput->m_X < x + 20 && g_pInput->m_Y > y - 20 && g_pInput->m_Y < y + 20) || (g_pInput->m_X>g_pInput->prev_X + IwGxGetDeviceWidth() / 2)) { g_pInput->prev_X = g_pInput->m_X; sceneSwitchComplete = false; g_pInput->Reset(); if(currentPage == 0) { CalendarScene* cal = (CalendarScene*)g_pSceneManager->Find("calscene"); g_pSceneManager->SwitchTo(cal, 1); labelMain->SetText("Calendar"); labelLeft->SetText("Events"); labelRight->SetText("News"); currentPage = 1; } else if(currentPage == 1) { EventsScene* events = (EventsScene*)g_pSceneManager->Find("eventsscene"); g_pSceneManager->SwitchTo(events, 1); labelMain->SetText("Events"); labelLeft->SetText("News"); labelRight->SetText("Cal."); currentPage = 2; } else if(currentPage == 2) { NewsScene* news = (NewsScene*)g_pSceneManager->Find("newsscene"); g_pSceneManager->SwitchTo(news, 1); labelMain->SetText("News"); labelLeft->SetText("Cal."); labelRight->SetText("Events"); currentPage = 0; } } else if ( (labelRight->HitTest(g_pInput->m_X, g_pInput->m_Y) && g_pInput->m_X > x - 20 && g_pInput->m_X < x + 20 && g_pInput->m_Y > y - 20 && g_pInput->m_Y < y + 20) || ((g_pInput->m_X) < (g_pInput->prev_X - (int)IwGxGetDeviceWidth() / 2)) ) { g_pInput->prev_X = g_pInput->m_X; sceneSwitchComplete = false; g_pInput->Reset(); if(currentPage == 0) { EventsScene* events = (EventsScene*)g_pSceneManager->Find("eventsscene"); g_pSceneManager->SwitchTo(events, 0); labelMain->SetText("Events"); labelLeft->SetText("News"); labelRight->SetText("Cal."); currentPage = 2; } else if(currentPage == 1) { NewsScene* news = (NewsScene*)g_pSceneManager->Find("newsscene"); g_pSceneManager->SwitchTo(news, 0); labelMain->SetText("News"); labelLeft->SetText("Cal."); labelRight->SetText("Events"); currentPage = 0; } else if(currentPage == 2) { CalendarScene* cal = (CalendarScene*)g_pSceneManager->Find("calscene"); g_pSceneManager->SwitchTo(cal, 0); labelMain->SetText("Cal."); labelLeft->SetText("Events"); labelRight->SetText("News"); currentPage = 1; } } g_pInput->Reset(); x = 0; y = 0; touched = false; } if(g_pInput->m_PrevTouched) { x = 0; y = 0; touched = false; } }