Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. boolean isButtonDown = false;
  2.  
  3. private void someFunction() {
  4.     if (buttonValue == true && isButtonDown == false) {
  5.         isButtonDown = true;
  6.  
  7.         // This code will only be run ONCE
  8.         // right when the button is first pressed
  9.     } else if (buttonValue == false && isButtonDown == true) {
  10.         isButtonDown = false
  11.  
  12.         // This code will be run ONCE
  13.         // right when the button is first released
  14.     } else if (buttonValue == true && isButtonDown == true) {
  15.         // This code will be run CONTINUOUSLY
  16.         // While the button is being held down
  17.  
  18.         // Don't put any code you want to run more than once here
  19.     } else if (buttonValue == false && isButtonDown == false) {
  20.         // This code will be run CONTINUOUSLY
  21.         // While the button is NOT being held down
  22.  
  23.         // Don't put any code you want to run more than once here
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement