- Home /
iPhone - finger keeps touching screen
Hi,
I would like to call a subroutine with various yield commands, as long as a finger is touching the screen. And I have two problems with that.
First: How do I recognize a sigle individual finger to stay on the screen? I usually work with TouchPhase, but there are only a command for a stationary touch, so if the finger is moved on the screen, the condition isnt true anymore.
And Second: How can I make a function, which will be called as long as variable or condition is true? So in the touch example: The finger is touching the screen -> a function is called so long, until the finger is released from the screen.
I really appreciate any help.
Answer by Fervent · Apr 19, 2011 at 09:39 PM
use a coroutine... on touchbegin start the coroutine.
add a while loop in your coroutine that checks to see if the phase = touchended which breaks the while loop and exits the coroutine. at the end of your while loop put a yield statement that will let control go until the next frame at which point the next iteration of the while loop will happen.
Your answer
![](https://koobas.hobune.stream/wayback/20220613123621im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple touch iPhone Buttons 0 Answers
How to display Swipe Marks on iPhone 1 Answer
Unity iPhone: AddForce to Object after Touch 0 Answers