官术网_书友最值得收藏!

Creating a new project

If you'd like more details and explanation about these steps, refer to the Creating a new Cardboard project section in Chapter 2, The Skeleton Cardboard Project, and follow along there:

  1. With Android Studio opened, create a new project. Let's name it CardboardBox and target Android 4.4 KitKat (API 19) with an Empty Activity.
  2. Add the Cardboard SDK common.aar and core.aar library files to your project as new modules, using File | New | New Module....
  3. Set the library modules as dependencies to the project app, using File | Project Structure.
  4. Edit the AndroidManifest.xml file as explained in Chapter 2, The Skeleton Cardboard Project, being careful to preserve the package name for this project.
  5. Edit the build.gradle file as explained in Chapter 2, The Skeleton Cardboard Project, to compile against SDK 22.
  6. Edit the activity_main.xml layout file as explained in Chapter 2, The Skeleton Cardboard Project.
  7. Edit the MainActivity Java class so that it extends CardboardActivity and implements CardboardView.StereoRenderer. Modify the class declaration line as follows:
    public class MainActivity extends CardboardActivity implements CardboardView.StereoRenderer {
  8. Add the stub method overrides for the interface (using intellisense implement methods or pressing Ctrl + I).
  9. At the top of the MainActivity class, add the following comments as placeholders for variables that we will be creating in this project:
    CardboardView.StereoRenderer {
       private static final String TAG = "MainActivity";
    
       // Scene variables
       // Model variables
       // Viewing variables
       // Rendering variables
  10. Lastly, edit onCreate() by adding the CardboadView instance as follows:
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            CardboardView cardboardView = (CardboardView) findViewById(R.id.cardboard_view);
            cardboardView.setRenderer(this);
            setCardboardView(cardboardView);  
        }
主站蜘蛛池模板: 平利县| 彭州市| 嵊州市| 邢台县| 高邮市| 东乌珠穆沁旗| 通城县| 定陶县| 泌阳县| 鲁甸县| 元阳县| 西安市| 永州市| 深州市| 青河县| 灵璧县| 定安县| 桦南县| 武威市| 湘乡市| 巴马| 曲周县| 百色市| 志丹县| 伊金霍洛旗| 三穗县| 大同市| 潜江市| 武定县| 泰安市| 桑植县| 嘉定区| 东平县| 伊春市| 肃宁县| 锡林浩特市| 枞阳县| 孟村| 班玛县| 岐山县| 峡江县|