Create an array of touches in Android?
Hey,
So I wondered whether it's possible to create an array to store ALL touches for a particular level. I want to base pause functionality on players' 2nd touch but cant seem to figure it out (yet).
From the code below, I want play to launch on click/tap and for play to pause on a second click/tap. At the moment however, the code doesn't understand what is a second touch (from what I can gather, the touch function reads each touch individually as opposed to being a cumulative touch count for the level).
Your help would be seriously appreciated, Cheers
void Play() { if (Input.GetMouseButtonDown(0) || Input.touchCount == 1) { //if clicked per standalone OR tapped
gameOn = true; levelTitle.CrossFadeAlpha(0.0f, 0.5f, false); } }
void PausePlay() //pauses game and is triggered when p is clicked
{
if (Input.GetKeyDown(KeyCode.P) || (Input.touchCount % 2 == 0)) //if p clicked OR taps are divisible by 2
{
if (Time.timeScale == 1)
{
ShowPaused();
Debug.Log("Paused Game");
}
else if (Time.timeScale == 0)
{
HidePaused();
Debug.Log("Unpaused Game");
}
}
}
Your answer
Follow this Question
Related Questions
When The Screen Is Touched Jump 0 Answers
Android Touch Double Jump - Not working 0 Answers
Android Controls 1 Answer
touch.position values clearification 0 Answers