From 1b1322d387fb4c35f4f1d448c1af430626840678 Mon Sep 17 00:00:00 2001 From: forteri76 Date: Sun, 18 May 2014 01:40:44 +0000 Subject: [PATCH] Fixed accelerometer based targeting in Puzzle game mode. --- AndroidManifest.xml | 4 +-- src/com/efortin/frozenbubble/HomeScreen.java | 2 +- src/org/jfedor/frozenbubble/GameView.java | 34 +++++++++++++++----- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index d9c4838..a88a9ce 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="29" + android:versionName="2.5"> 1) { + mPlayer2.setGameRef(null); + mFrozenGame2 = null; mFrozenGame2 = new FrozenGame(mBackground, mBubbles, mBubblesBlind, mFrozenBubbles, mTargetedBubbles, mBubbleBlink, mGameWon, mGameLost, @@ -1837,6 +1842,8 @@ public void newGame() { } private void nextLevel() { + mPlayer1.setGameRef(null); + mFrozenGame1 = null; mFrozenGame1 = new FrozenGame(mBackground, mBubbles, mBubblesBlind, mFrozenBubbles, mTargetedBubbles, mBubbleBlink, mGameWon, mGameLost, @@ -1844,6 +1851,7 @@ private void nextLevel() { mCompressorHead, mCompressor, mLauncher, mSoundManager, mLevelManager, mHighScoreManager); + mPlayer1.setGameRef(mFrozenGame1); if (mHighScoreManager != null) { mHighScoreManager.startLevel(mLevelManager.getLevelIndex()); } @@ -2074,6 +2082,7 @@ private void scaleFrom(BmpWrap image, Bitmap bmp) { */ public void setPlayerAction(PlayerAction newAction) { VirtualInput playerRef; + FrozenGame gameRef; if (newAction.playerID == VirtualInput.PLAYER1) { playerRef = mPlayer1; @@ -2085,6 +2094,13 @@ else if (newAction.playerID == VirtualInput.PLAYER2) { return; } + if (playerRef.mGameRef != null) { + gameRef = playerRef.mGameRef; + } + else { + return; + } + if (mGameThread != null) mGameThread.updateStateOnEvent(null); @@ -2098,21 +2114,21 @@ else if (newAction.playerID == VirtualInput.PLAYER2) { (newAction.nextBubbleColor < 8) && (newAction.newNextBubbleColor > -1) && (newAction.newNextBubbleColor < 8)) { - playerRef.mGameRef.setLaunchBubbleColors(newAction.launchBubbleColor, - newAction.nextBubbleColor, - newAction.newNextBubbleColor); + gameRef.setLaunchBubbleColors(newAction.launchBubbleColor, + newAction.nextBubbleColor, + newAction.newNextBubbleColor); } /* * Set the launcher aim position. */ - playerRef.mGameRef.setPosition(newAction.aimPosition); + gameRef.setPosition(newAction.aimPosition); /* * Process a compressor lower request. */ if (newAction.compress) { - playerRef.mGameRef.lowerCompressor(true); + gameRef.lowerCompressor(true); } /* @@ -2142,14 +2158,16 @@ else if (newAction.playerID == VirtualInput.PLAYER2) { * Set the current value of the attack bar. */ if (newAction.attackBarBubbles > -1) { - playerRef.mGameRef.malusBar.setAttackBubbles(newAction.attackBarBubbles, - newAction.attackBubbles); + gameRef.malusBar.setAttackBubbles(newAction.attackBarBubbles, + newAction.attackBubbles); } } } public void setPosition(double value) { - mLocalInput.mGameRef.setPosition(value); + if (mLocalInput.mGameRef != null) { + mLocalInput.mGameRef.setPosition(value); + } } public void setRunning(boolean b) {