O'Reilly logo

Cardboard VR Projects for Android by Matt Schoen, Jonathan Linowes

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required