Skip to content

Commit

Permalink
Fixed main menu crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Indexu committed Nov 5, 2017
1 parent 853e20a commit 51f06e1
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions src/core/src/com/ru/tgra/ourcraft/OurCraftGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,18 @@ public void create ()

private void mainMenuInput()
{
if(Gdx.input.isKeyPressed(Input.Keys.ENTER) && GameManager.loaded)
if((Gdx.input.isKeyPressed(Input.Keys.ENTER) || Gdx.input.isKeyPressed(Input.Keys.SPACE) ) && GameManager.loaded)
{
GameManager.mainMenu = false;
GameManager.createWorld();
startGame();
}
}

private void startGame()
{
GameManager.mainMenu = false;
GameManager.createWorld();
}

private void mainMenuCreateWorld()
{
switch (step)
Expand Down Expand Up @@ -465,7 +470,6 @@ private void drawMainMenu()
@Override
public void render ()
{
System.out.print("\r \r");
input();
update();
display();
Expand Down Expand Up @@ -546,24 +550,38 @@ private void initInput()
@Override
public boolean touchDown(int x, int y, int pointer, int button)
{
if (button == Input.Buttons.LEFT)
if (GameManager.mainMenu)
{
if (GameManager.loaded)
{
startGame();
return true;
}
}
else if (button == Input.Buttons.LEFT)
{
if (GameManager.player.getTargetBlock() != null)
{
GameManager.player.getTargetBlock().destroy();
return true;
}
}

if (button == Input.Buttons.RIGHT)
else if (button == Input.Buttons.RIGHT)
{
GameManager.player.placeBlock();
return true;
}

return false;
}

@Override public boolean scrolled(int amount)
{
if (GameManager.mainMenu)
{
return false;
}

if (amount == -1)
{
GameManager.player.scrollDownSelectedBlock();
Expand Down

0 comments on commit 51f06e1

Please sign in to comment.