Skip to content

Commit

Permalink
Fix play/pause button when reloading
Browse files Browse the repository at this point in the history
  • Loading branch information
grandao committed May 2, 2019
1 parent 3f0c90f commit 0f405ca
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
9 changes: 8 additions & 1 deletion Assets/GameController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class GameController : MonoBehaviour
Node current;

System.Random rng = new System.Random();

bool is_playing = false;

static GameController instance;

Expand Down Expand Up @@ -61,6 +61,7 @@ void Start()

return ret;
});
is_playing = true;
}

// Update is called once per frame
Expand Down Expand Up @@ -181,11 +182,13 @@ public void SetBPM(int bpm)
public void Play()
{
scheduler.StartTick();
is_playing = true;
}

public void Pause()
{
scheduler.StopTick();
is_playing = false;
}

public void Reload()
Expand All @@ -194,6 +197,10 @@ public void Reload()
current = CreateNode(new Vector3(-2, 2, 0)).GetComponent<Node>();
Start();
}
public bool IsPlaying()
{
return is_playing;
}
}


Expand Down
21 changes: 9 additions & 12 deletions Assets/PlayController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

public class PlayController : MonoBehaviour
{
bool toggle = false;
GameObject bar;
GameObject arrow;
private void Awake()
Expand All @@ -21,24 +20,22 @@ void Start()
// Update is called once per frame
void Update()
{

}

public void Click()
{
if (toggle)
if (GameController.GetInstance().IsPlaying())
{
GameController.GetInstance().Play();
bar.SetActive(true);
arrow.SetActive(false);
}
else
} else
{
GameController.GetInstance().Pause();
bar.SetActive(false);
arrow.SetActive(true);
}
}

toggle = !toggle;
public void Click()
{
if (GameController.GetInstance().IsPlaying())
GameController.GetInstance().Pause();
else
GameController.GetInstance().Play();
}
}

0 comments on commit 0f405ca

Please sign in to comment.