Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- boolean isButtonDown = false;
- private void someFunction() {
- if (buttonValue == true && isButtonDown == false) {
- isButtonDown = true;
- // This code will only be run ONCE
- // right when the button is first pressed
- } else if (buttonValue == false && isButtonDown == true) {
- isButtonDown = false
- // This code will be run ONCE
- // right when the button is first released
- } else if (buttonValue == true && isButtonDown == true) {
- // This code will be run CONTINUOUSLY
- // While the button is being held down
- // Don't put any code you want to run more than once here
- } else if (buttonValue == false && isButtonDown == false) {
- // This code will be run CONTINUOUSLY
- // While the button is NOT being held down
- // Don't put any code you want to run more than once here
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement