- Android Game Programming by Example
- John Horton
- 297字
- 2021-07-16 13:50:02
Deploying the game
Now, we can run our game to see our spaceship floating through space (starting at 50 pixels on the x axis and 50 pixels on the y axis).
Android Studio enables us to fairly quickly create emulators, on which we can test our games on a development PC. However, even the most simple of games will not run well on an emulator. When we start testing things like player input, the experience is so awful that it is best to avoid using emulators completely.
The solution is to carry out debugging on a real Android device. It is very easy to prepare for this.
Debugging on an Android device
The first thing to do is to visit your device manufacturer's website and obtain and install any drivers that are required for your device and operating system.
The next few steps will setup the Android device for debugging. Note that different manufacturers structure the menu options slightly differently than others. The following sequence is probably very close, if not exact to enable debugging on most devices.
- Tap the Settings menu option or the Settings app.
- Tap Developer options.
- Tap the checkbox for USB Debugging.
- Connect your Android device to the USB port of your development system. The next image shows on the Android tab. At the bottom of the Android Studio UI, you can see that Samsung GT-I9100 Android 4.1.2 (API 16) has been detected:
- Click on the Play icon from the Android Studio toolbar:
- When prompted, click on OK to run the game on your chosen device.
The game will now run on the device. Any output or errors can be seen in the logcat window, also on the Android tab:
Watch with awe as our player's spaceship moves slowly from left to right.