@Override protected synchronized void onResume() { super.onResume(); if (mEngine != null && !mEngine.isRunning()) { mEngine.start(); } }
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case ConnectionHandler.REQUEST_ENABLE_BT: { if (resultCode == Activity.RESULT_OK) { Toast.makeText(this, "Successfully enabled bluetooth.", Toast.LENGTH_SHORT).show(); btHandler.onBtEnabled(); } else { Toast.makeText( this, "Could not enable bluetooth, War Yachts will now exit.", Toast.LENGTH_LONG) .show(); btHandler.reset(); finish(); } break; } case ConnectionHandler.REQUEST_ENABLE_DISCOVERY: { if (resultCode == ConnectionHandler.DEFAULT_DISCOVERY_TIME) { // Notify the user that discovery was enabled, Toast.makeText( this, "Successfully enabled discovery, waiting for connection", Toast.LENGTH_SHORT) .show(); // Set up connection listener in ConnectionHandler btHandler.onDiscoveryEnabled(); // Create game for when a connection is established prepareHostGameInstanceCallback.onCallback(); } else { Toast.makeText( this, "Could not enable discovery. Try searching instead of hosting.", Toast.LENGTH_SHORT) .show(); btHandler.reset(); } break; } default: { // We obviously don't know what this is about, maybe someone // above does // TAKE ME OUT // HOW TO PRINT TO SCREEN Toast.makeText( getBaseContext(), "UNHANDLED REQUEST CODE, WE SHOULD NOT BE HERE!", Toast.LENGTH_SHORT) .show(); super.onActivityResult(requestCode, resultCode, data); } } }
// Called when user pushes the back button @Override public void onBackPressed() { // Reset busy and stop performing connection activities btHandler.reset(); // If the scenario doesn't handle back presses, pass it up if (currentScenario == null || !currentScenario.handleBackPress()) super.onBackPressed(); }
@Override protected void onDestroy() { Log.d("Gameactivity", "Destroy"); // if (this.isGameLoaded()) { // System.exit(0); // } super.onDestroy(); }
@Override protected void onPause() { Log.i("Gameactivity", "Pause"); super.onPause(); if (mEngine != null && mEngine.isRunning()) { mEngine.stop(); } }
// TODO cannot make this actually execute when the game closes!!! @Override public synchronized void onGameDestroyed() { /*try{ GameContext.getSharedInstance().leaveGame(); } catch(Exception e){}*/ GCMConnector.destroy(); super.onGameDestroyed(); }
private void showAppRating() { activity.runOnUiThread( new Runnable() { @Override public void run() { AppRater.app_launched(activity); } }); }
@Override public synchronized void onPauseGame() { // TODO Auto-generated method stub super.onPauseGame(); if (StartActivity.mMusic.isPlaying()) { StartActivity.mMusic.pause(); } }
@Override protected void onStart() { super.onStart(); Log.d("GameActivity", "Start"); // Bind to the service Intent intent = new Intent(this, SpaceCrackService.class); intent.putExtra("username", SpaceCrackApplication.user.username); bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE); }
public void loadSplashScreen() { BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/"); splashTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 1024, 1024, TextureOptions.BILINEAR); splashTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( splashTextureAtlas, activity, "splash.jpg", 0, 0); splashTextureAtlas.load(); }
@Override protected void onStop() { if (boundToService) { unbindService(serviceConnection); } Log.d("GameActivity", "Stop"); super.onStop(); }
public void loadSplashResources() { BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/"); splashTA = new BitmapTextureAtlas(activity.getTextureManager(), 256, 256); splashTR = BitmapTextureAtlasTextureRegionFactory.createFromAsset( splashTA, activity, "splash12.png", 0, 0); splashTA.load(); }
private void loadChalkFont() { if (chalkFontTextureAtlas != null) { return; } FontFactory.setAssetBasePath("font/"); chalkFontTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 512, 512, TextureOptions.BILINEAR); chalkFont = FontFactory.createStrokeFromAsset( activity.getFontManager(), chalkFontTextureAtlas, activity.getAssets(), "ChalkPaint.ttf", 50, true, Color.WHITE, 2, Color.WHITE); chalkFontTextureAtlas.load(); chalkFont.load(); }
private void loadBlackFont() { if (gameFontTextureAtlas != null) { return; } FontFactory.setAssetBasePath("font/"); gameFontTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 512, 512, TextureOptions.BILINEAR); blackFont = FontFactory.createStrokeFromAsset( activity.getFontManager(), gameFontTextureAtlas, activity.getAssets(), "font1.ttf", 50, true, Color.BLACK, 2, Color.BLACK); gameFontTextureAtlas.load(); blackFont.load(); }
public void loadLoadingResources() { if (loadingTextureAtlas != null) { loadingTextureAtlas.load(); return; } BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/loading/"); loadingTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 1024, 1024, TextureOptions.BILINEAR); loadingTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( loadingTextureAtlas, activity, "background.png", 0, 0); loadingTextureAtlas.load(); }
@Override public synchronized void onResumeGame() { // TODO Auto-generated method stub // sa.finish(); super.onResumeGame(); mainMenuScene.registerEntityModifier( new ScaleAtModifier(0.5f, 0.0f, 1.0f, CAMERA_WIDTH / 2, CAMERA_HEIGHT / 2)); mStaticMenuScene.registerEntityModifier( new ScaleAtModifier(0.5f, 0.0f, 1.0f, CAMERA_WIDTH / 2, CAMERA_HEIGHT / 2)); if (audioOptions.getBoolean("musicOn", true)) { StartActivity.mMusic.resume(); } }
private void loadAboutGraphics() { BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/about/"); aboutTextureAtlas = new BuildableBitmapTextureAtlas( activity.getTextureManager(), 1024, 1024, TextureOptions.BILINEAR); aboutBackgroundTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( aboutTextureAtlas, activity, "background.jpg"); try { aboutTextureAtlas.build( new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(0, 0, 1)); aboutTextureAtlas.load(); } catch (ITextureAtlasBuilder.TextureAtlasBuilderException e) { e.printStackTrace(); } }
private void loadMainMenuGraphics() { if (menuTextureAtlas != null) { menuTextureAtlas.load(); return; } BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/menu/"); menuTextureAtlas = new BuildableBitmapTextureAtlas( activity.getTextureManager(), 1024, 1024, TextureOptions.BILINEAR); menuBackgroundTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( menuTextureAtlas, activity, "background.jpg"); buttonAboutTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( menuTextureAtlas, activity, "menu_help.png"); buttonExitTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( menuTextureAtlas, activity, "menu_exit.png"); buttonNewGameTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( menuTextureAtlas, activity, "menu_new.png"); buttonOptionsTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( menuTextureAtlas, activity, "menu_options.png"); buttonHighScoreTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( menuTextureAtlas, activity, "menu_high.png"); buttonMultiplayerTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( menuTextureAtlas, activity, "menu_multiplayer.png"); try { menuTextureAtlas.build( new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(0, 0, 1)); menuTextureAtlas.load(); } catch (ITextureAtlasBuilder.TextureAtlasBuilderException e) { e.printStackTrace(); } }
public void loadMenuResources() { BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/"); ResourceManager.playBitmapTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 256, 256, TextureOptions.BILINEAR); ResourceManager.optionsBitmapTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 256, 256, TextureOptions.BILINEAR); ResourceManager.scoresBitmapTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 256, 256, TextureOptions.BILINEAR); ResourceManager.instructionsTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 256, 256, TextureOptions.BILINEAR); ResourceManager.exitBitmapTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 256, 256, TextureOptions.BILINEAR); // load the button texture regions mMenuBgTextureAtlas = new BitmapTextureAtlas( activity.getTextureManager(), (int) camera.getWidth(), (int) camera.getHeight(), TextureOptions.DEFAULT); mBgTexture = BitmapTextureAtlasTextureRegionFactory.createFromAsset( mMenuBgTextureAtlas, activity, "image.jpg", 0, 0); ResourceManager.newGameTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( ResourceManager.playBitmapTextureAtlas, activity, "new_game.PNG", 0, 0); ResourceManager.optionsTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( ResourceManager.optionsBitmapTextureAtlas, activity, "settings1.png", 0, 0); ResourceManager.quitTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( ResourceManager.exitBitmapTextureAtlas, activity, "exit.PNG", 0, 50); ResourceManager.scoresTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( ResourceManager.scoresBitmapTextureAtlas, activity, "menu_reset.png", 0, 0); ResourceManager.instructionsTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( ResourceManager.instructionsTextureAtlas, activity, "instructions.PNG", 0, 0); ResourceManager.optionsBitmapTextureAtlas.load(); ResourceManager.playBitmapTextureAtlas.load(); ResourceManager.scoresBitmapTextureAtlas.load(); ResourceManager.instructionsTextureAtlas.load(); ResourceManager.exitBitmapTextureAtlas.load(); ResourceManager.mMenuBgTextureAtlas.load(); }
private void loadHighScoreGraphics() { if (recordTextureAtlas != null) { recordTextureAtlas.load(); } BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/highscore/"); recordTextureAtlas = new BuildableBitmapTextureAtlas( activity.getTextureManager(), 1024, 512, TextureOptions.BILINEAR); recordBackgroundTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( recordTextureAtlas, activity, "background.png"); try { recordTextureAtlas.build( new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(0, 0, 0)); recordTextureAtlas.load(); } catch (ITextureAtlasBuilder.TextureAtlasBuilderException e) { e.printStackTrace(); } }
private void loadGameTypeGraphics() { if (gameTypeTextureAtlas != null) { gameTypeTextureAtlas.load(); } BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/gametype/"); gameTypeTextureAtlas = new BuildableBitmapTextureAtlas( activity.getTextureManager(), 1024, 1024, TextureOptions.BILINEAR); backgroundGameTypeTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( gameTypeTextureAtlas, activity, "background.png"); starGoldTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( gameTypeTextureAtlas, activity, "goldStar.png"); starWhiteTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( gameTypeTextureAtlas, activity, "whiteStar.png"); awesomeTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( gameTypeTextureAtlas, activity, "awesome.png"); lockTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( gameTypeTextureAtlas, activity, "lock.png"); playButtonTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( gameTypeTextureAtlas, activity, "playButton.png"); try { gameTypeTextureAtlas.build( new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(1, 1, 1)); gameTypeTextureAtlas.load(); } catch (ITextureAtlasBuilder.TextureAtlasBuilderException e) { e.printStackTrace(); } }
private void loadGameGraphics() { if (gameTextureAtlas != null) { gameTextureAtlas.load(); } BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/game/"); gameTextureAtlas = new BuildableBitmapTextureAtlas( activity.getTextureManager(), 1024, 1024, TextureOptions.BILINEAR); backgroundGameTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( gameTextureAtlas, activity, "background.png"); buttonOkTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( gameTextureAtlas, activity, "button_ok.png"); buttonNoTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( gameTextureAtlas, activity, "button_no.png"); lifeBarBorderTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( gameTextureAtlas, activity, "bar_border.png"); playerRegion = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset( gameTextureAtlas, activity, "blackFish.png", 2, 1); try { gameTextureAtlas.build( new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(0, 0, 1)); gameTextureAtlas.load(); } catch (ITextureAtlasBuilder.TextureAtlasBuilderException e) { e.printStackTrace(); } }
@Override public void onPauseGame() { super.onPauseGame(); this.disableAccelerationSensor(); }
@Override public void onResumeGame() { super.onResumeGame(); this.enableAccelerationSensor(this); }
@Override protected void onDestroy() { super.onDestroy(); System.exit(0); }
@Override public synchronized void onResumeGame() { Log.d("GameActivity", "Resume Game"); if (this.mEngine != null) super.onResumeGame(); }
public void loadGameResources() { BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/"); SoundFactory.setAssetBasePath("sfx/"); MusicFactory.setAssetBasePath("sfx/"); condomTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 64, 64); chickenTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 64, 64); tabletTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 64, 64); waterTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 64, 64); garlicTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 32, 32); pineappleTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 64, 64); alcoholTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 32, 64); blueTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 256, 256); redTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 256, 256); razorTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 256, 256); winTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 1024, 512); lossTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 1024, 512); pauseTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 64, 64); cigarreteTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 64, 64); soyaTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 32, 16); bonusTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 64, 64); // create the texture regions of the different Sprites condomTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( condomTextureAtlas, activity, "condom2f.png", 0, 0); chickenTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( chickenTextureAtlas, activity, "chichen_final.png", 0, 0); tabletTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( tabletTextureAtlas, activity, "tab.png", 0, 0); garlicTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( garlicTextureAtlas, activity, "garlicf.png", 0, 0); pineappleTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( pineappleTextureAtlas, activity, "pinef.png", 0, 0); waterTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( waterTextureAtlas, activity, "water.png", 0, 0); alcoholTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( alcoholTextureAtlas, activity, "waragi.png", 0, 0); blueTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( blueTextureAtlas, activity, "blue3.png", 0, 0); redTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( redTextureAtlas, activity, "red2.png", 0, 0); razorTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( razorTextureAtlas, activity, "razor.png", 0, 0); winTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( winTextureAtlas, activity, "win.png", 0, 0); lossTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( lossTextureAtlas, activity, "loss.png", 0, 0); cigarreteTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( cigarreteTextureAtlas, activity, "cigaret5.png", 0, 0); soyaTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( soyaTextureAtlas, activity, "sayaf.png", 0, 0); bonusTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( bonusTextureAtlas, activity, "health.png", 0, 0); pauseTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( pauseTextureAtlas, activity, "pause.png", 0, 0); mBackgroundTexture = new BitmapTextureAtlas( engine.getTextureManager(), (int) camera.getWidth(), (int) camera.getHeight(), TextureOptions.DEFAULT); mBgTexture = BitmapTextureAtlasTextureRegionFactory.createFromAsset( mBackgroundTexture, activity, "game_background.jpg", 0, 0); // scoreFontTexture = new BitmapTextureAtlas(engine.getTextureManager(), // 256, 256, TextureOptions.BILINEAR_PREMULTIPLYALPHA); // FontFactory.setAssetBasePath("font/"); // ResourceManager.mFont = FontFactory.createFromAsset(scoreFontTexture, // engine.getTextureManager(), // "Droid.ttf", FONT_SIZE, true, Color.BLACK); ResourceManager.mFont = FontFactory.create( engine.getFontManager(), engine.getTextureManager(), 256, 256, Typeface.create(Typeface.DEFAULT, Typeface.BOLD), FONT_SIZE); // Load our "sound.mp3" file into a Sound object try { mGameTapSound = SoundFactory.createSoundFromAsset(engine.getSoundManager(), activity, "tap.mp3"); badFoodSound = SoundFactory.createSoundFromAsset(engine.getSoundManager(), activity, "plast.mp3"); } catch (IOException e) { e.printStackTrace(); } // Load our "music.mp3" file into a music object try { gameMusic = MusicFactory.createMusicFromAsset(engine.getMusicManager(), activity, "welcome.mp3"); } catch (IOException e) { e.printStackTrace(); } ResourceManager.mFont.load(); ResourceManager.mBackgroundTexture.load(); condomTextureAtlas.load(); chickenTextureAtlas.load(); tabletTextureAtlas.load(); pineappleTextureAtlas.load(); waterTextureAtlas.load(); alcoholTextureAtlas.load(); garlicTextureAtlas.load(); blueTextureAtlas.load(); redTextureAtlas.load(); razorTextureAtlas.load(); winTextureAtlas.load(); lossTextureAtlas.load(); pauseTextureAtlas.load(); cigarreteTextureAtlas.load(); soyaTextureAtlas.load(); bonusTextureAtlas.load(); }
@Override public synchronized void onGameCreated() { super.onGameCreated(); Log.d("GameActivity", "Game created"); }
@Override public void onDestroy() { // unregisterReceiver(deviceReceiver); super.onDestroy(); }
@Override protected void onCreate(Bundle pSavedInstanceState) { super.onCreate(pSavedInstanceState); Log.d("GameActivity", "Create"); loadData(); }