Gamemenu intergration. pause function working again.

This commit is contained in:
Administrator
2014-02-20 11:44:48 +01:00
parent 812308b869
commit 3cbc26b42d
4 changed files with 94 additions and 86 deletions
+20 -35
View File
@@ -33,7 +33,7 @@ public class GamePlay extends GameStateInterface
{
mp.pause();
SetGameState(GS_PAUSED);
SetGameState(GS_PAUSED, false);
}
@Override
@@ -52,7 +52,7 @@ public class GamePlay extends GameStateInterface
else
{
mp.start();
SetGameState(GS_PLAYING);
SetGameState(GS_PLAYING, false);
}
}
}
@@ -69,28 +69,6 @@ public class GamePlay extends GameStateInterface
}
}
@Override
public void SetGameState(int gameState)
{
GameState = gameState;
switch(GameState)
{
case GS_LOAD:
{
Load();
break;
}
case GS_START:
{
StartGame();
break;
}
}
canvasView.OnGameStateChanged(GameState);
}
@Override
public void SetGameState(int gameState, boolean isPostBack)
{
@@ -108,9 +86,15 @@ public class GamePlay extends GameStateInterface
StartGame();
break;
}
case GS_RESUME:
{
Resume();
break;
}
}
canvasView.OnGameStateChanged(GameState, isPostBack);
if (!isPostBack)
canvasView.OnGameStateChanged(GameState);
}
// Set
@@ -144,10 +128,6 @@ public class GamePlay extends GameStateInterface
return GameState;
}
// Internal.
CanvasView canvasView;
Activity activity = null;
// Variabelen
Resources r;
@@ -480,7 +460,7 @@ public class GamePlay extends GameStateInterface
mp.setLooping(true);
mp.start();
SetGameState(GS_PLAYING);
SetGameState(GS_PLAYING, false);
handler.removeCallbacksAndMessages(null);
handler.postDelayed(runnable, 100);
@@ -488,7 +468,7 @@ public class GamePlay extends GameStateInterface
private void Load()
{
SetGameState(GS_LOADING);
SetGameState(GS_LOADING, false);
// Set Display Info.
Display display = activity.getWindowManager().getDefaultDisplay();
@@ -515,7 +495,7 @@ public class GamePlay extends GameStateInterface
// Audio
mp = MediaPlayer.create(activity, R.raw.tetris_a);
SetGameState(GS_READY);
SetGameState(GS_READY, false);
}
private void LoadSprites()
@@ -1360,8 +1340,7 @@ public class GamePlay extends GameStateInterface
onPause();
else
{
mp.start();
SetGameState(GS_PLAYING);
SetGameState(GS_RESUME, false);
}
}
}
@@ -1378,6 +1357,12 @@ public class GamePlay extends GameStateInterface
}
}
private void Resume()
{
mp.start();
SetGameState(GS_PLAYING, false);
}
private void InputsGamePlaying(float x, float y, boolean Released)
{
int moveX = (int)((x / Width) * 90);
@@ -1460,7 +1445,7 @@ public class GamePlay extends GameStateInterface
//spawn new block
if (!SpawnBlock())
{
SetGameState(GS_GAMEOVER);
SetGameState(GS_GAMEOVER, false);
mp.stop();
canvasView.postInvalidate();