Highlighting the current shortcut
When the user gazes at a shortcut, it should be able to indicate that it is selectable. In the next section, we'll wire it up to highlight the selected item and to actually launch the corresponding app.
The trick here is to determine which slot is in front of the user. To highlight it, we'll brighten the text color.
Let's write a helper method to determine which slot is currently in the gaze, based on the headOffset
variable (which was calculated from the head yaw angle). Add the getSlot
method to the OverlayView
class:
public int getSlot() { int slotOffset = shortcutWidth/2 - headOffset; slotOffset /= shortcutWidth; if(slotOffset < 0) slotOffset = 0; if(slotOffset >= shortcuts.size()) slotOffset = shortcuts.size() ...
Get Cardboard VR Projects for Android now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.