Treasure Hunt sample app-（寻宝示例app）
You will build the Treasure Hunt app, which uses the following features of the Google VR SDK:
Binocular rendering: A split-screen view for each eye in VR.双目视觉效果：在VR 里 每只眼睛分屏视图。
Spatial audio: Sound seems to come from specific areas of the VR world.空间音频：声音似乎来自世界VR的特定区域。
Head movement tracking: The VR world view updates as the user moves their head.头部运动跟踪：根据用户的头部移动更新VR的场景
Trigger input: The user can interact with the VR world by pressing a button.触发输入:用户按下一个按钮就可以与虚拟世界互动。
In this game, you'll look around the game world to find and collect objects as quickly as possible. It's a basic game, but it demonstrates the core features of the Google VR SDK.
Open and run Treasure Hunt-打开并运行寻宝游戏
Building the sample app requires:
Android Studio, 1.0 or higher.
Version 23 of the Android SDK.
Gradle 23.0.1 or higher. Android Studio will allow you to upgrade if your installed version is too low.
A physical Android device running Android 4.4 (KitKat) or higher.
Download the sample code-下载示例代码
Clone the sample app from the
repository by running the following command:
git clone https://github.com/googlevr/gvr-android-sdk.git
Build the sample app-编译示例程序
Open Android Studio. On the Welcome to Android Studio screen, choose Open an existing Android Studio project, and select the
android-sdkdirectory. Android Studio will display the various gradle modules on the Project tab on the left side and the various run targets on the top toolbar.
打开 Android Studio。在Android Studio 欢迎屏幕上,选择打开一个已存在Android Studio 项目,并选择Android sdk目录。Android Studio 将显示项目的各种gradle模块选项卡左边和顶部工具栏上的各种运行目标。
Connect your phone to your machine, select the samples-treasurehunt target and click Run to compile and run the application on your phone.
For more information about the code behind the Treasure Hunt game, see our explanation of it in the samples section.
更多信息背后的代码寻宝游戏,看到我们的 explanation of it in the samples section.
Start your own project
Using Android Studio
After you've read up on the Google VR SDK for Android, it'll be time to create your own applications. Here's how.
First, grab all the required .AAR files from the libraries folder of the sdk. To determine which .AARs you need to depend on, you can examine the build.gradle files of the various sample
apps. For example,samples/treasurehunt/build.gradle's dependency section has the following entries:
This indicates that an application similar to the Treasure Hunt sample needs the audio, common, and core libraries.
Create new modules for each of these libraries. Using Android Studio's GUI, this can be done via File -> New -> New Module. Select Import .JAR/.AAR Package. Locate one of the .AARs and import it.
Then add this new module as a dependency to your main app via File > Project Structure > Modules (on the left side's section list) > YOUR APP's MODULE NAME > Dependencies (on the right side's tab list) -> '+' -> Module Dependency.
Once this is done for all of the required libraries, you will be able to reference code in the Google VR SDK in your app.
Directly using Gradle
Using the steps above will cause Android Studio to generate new modules and edit your .gradle files automatically. Alternatively, you can directly include the .AARs in your application's module by editing that specific module's build.gradlefile and adding the following entries:
This will tell Gradle to look in the libs subdirectory of your module for the three .AARs. Create that libs subdirectory inside your module's directory and copy the .AARs there. You will need to repeat this for every module that uses those .AARs which will lead to many duplicate .AARs as your project becomes more complex.