Created
March 20, 2018 10:41
-
-
Save ssaurel/3323d38f84b44bc0a97ca8281b96fd66 to your computer and use it in GitHub Desktop.
keyForCoords method for the PianoView on the SSaurel's Channel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Key keyForCoords(float x, float y) { | |
for (Key k : blacks) { | |
if (k.rect.contains(x,y)) { | |
return k; | |
} | |
} | |
for (Key k : whites) { | |
if (k.rect.contains(x,y)) { | |
return k; | |
} | |
} | |
return null; | |
} | |
private void releaseKey(final Key k) { | |
handler.postDelayed(new Runnable() { | |
@Override | |
public void run() { | |
k.down = false; | |
handler.sendEmptyMessage(0); | |
} | |
}, 100); | |
} | |
private Handler handler = new Handler() { | |
@Override | |
public void handleMessage(Message msg) { | |
invalidate(); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment