Home | History | Annotate | Download | only in games
      1 page.title=Building TV Games
      2 page.tags=tv, games, controller
      3 helpoutsWidget=true
      4 page.image=images/games/game-controller-buttons_2x_crop.png
      5 page.metaDescription=How to bring your games to Android TV, including recommendations and examples.
      6 page.article=true
      7 
      8 @jd:body
      9 
     10 <div id="qv-wrapper">
     11 <div id="qv">
     12   <h2>In this document</h2>
     13   <ol>
     14     <li><a href="#display">Display</a></li>
     15     <li><a href="#control">Input Devices</a></li>
     16     <li><a href="#manifest">Manifest</a></li>
     17     <li><a href="#gpgs">Google Play Game Services</a></li>
     18     <li><a href="#web">Web</a></li>
     19   </ol>
     20 </div>
     21 </div>
     22 
     23 <p>
     24   The television screen presents a number of considerations that may be new to mobile game
     25   developers. These areas include its large size, its control scheme, and the fact that all players
     26   are viewing it simultaneously.
     27 </p>
     28 
     29 
     30 <h2 id="display">Display</h2>
     31 <p>
     32   The two main things to keep in mind when developing games for the TV screen are its nature as a
     33   shared display and the need to design your game for a landscape orientation.
     34 </p>
     35 
     36 
     37 <h3 id="shared-display">Consider the shared display</h3>
     38 
     39 <p>
     40   A living-room TV poses design challenges for multiplayer games, in that all players can see
     41   everything. This issue is especially relevant to games (such as card games or strategy games)
     42   that rely on each players possession of hidden information.
     43 </p>
     44 
     45 <p>
     46   Some mechanisms you can implement to address the problem of one players eavesdropping on
     47   anothers information are:
     48 </p>
     49 
     50 <ul>
     51   <li>A blinder on the screen to help conceal information. For example, in a turn-based game like a
     52     word or card game, one player at a time might view the display. When the player finishes a move,
     53     the game allows him or her to cover the screen with a blinder that blocks anyone from viewing
     54     secret information. When the next player begins a turn, the blinder opens to reveal his or her
     55     own information.
     56   </li>
     57   <li>A companion app, running on a phone or tablet, can enable a player to conceal information by
     58     serving as a second screen.
     59   </li>
     60 </ul>
     61 
     62 
     63 <h3 id="landscape-display">Support landscape display</h3>
     64 
     65 <p>
     66   A TV is always sideways: You cant turn it, and there is no portrait orientation. Always design
     67   your TV games to be displayed in landscape mode.
     68 </p>
     69 
     70 
     71 <h2 id="control">Input Devices</h2>
     72 
     73 <p>
     74   TVs don't have touch interfaces, so it's even more important to get your controls right and make
     75   sure players find them intuitive and fun to use. Handling controllers
     76   also introduces some other issues to pay attention to, like keeping track of multiple
     77   controllers, and handling disconnects gracefully.
     78 </p>
     79 
     80 <h3 id="d-pad">Support D-pad controls</h3>
     81 
     82 <p>
     83   Plan your control scheme around a directional pad (D-pad) control, since this control set is the
     84   default for Android TV devices. The player needs to be able to use a D-Pad in all aspects of the
     85   game&mdash;not just controlling core gameplay, but also navigating menus and ads. For this reason, you
     86   should also ensure that your Android TV game does not refer to a touch interface. For example, an
     87   Android TV game should not tell a player to "<em>Tap</em> here to continue."
     88 </p>
     89 
     90 <p>
     91   How you shape the player's interaction with the controller can be key to achieving a great user
     92   experience:
     93 </p>
     94 
     95 <ul>
     96   <li>
     97     <strong>Communicate Controller Requirements up Front</strong>. Use your Google Play description
     98     to communicate to the player any expectations about controllers. If a game is better suited to
     99     a gamepad with a joystick than one with only a D-pad, make this fact clear. A player who uses
    100     an ill-suited controller for a game is likely to have a subpar experience and penalize your
    101     game in the ratings.
    102   </li>
    103   <li>
    104     <strong>Use Consistent Button Mapping</strong>. Intuitive and flexible button mapping is key
    105     to a good user experience. For example, you should adhere to accepted customs by using the A button
    106     to <em>Accept</em>, and the B button to <em>Cancel</em>. You can also offer flexibility
    107     in the form of remappability. For more information about button mapping, see <a href=
    108     "http://developer.android.com/training/game-controllers/controller-input.html">Handling
    109     Controller Actions</a>.
    110   </li>
    111   <li>
    112     <strong>Detect Controller Capabilities and Adjust Accordingly</strong>. Query the controller
    113     about its capabilities in order to optimize the match between controller and game. For example,
    114     you may intend for a player to steer an object by waving the controller in the air. If a
    115     player's controller lacks accelerometer and gyroscope hardware, however, waving will not work.
    116     So, your game should query the controller and if motion detection is not
    117     supported, switch over to an alternative, available control scheme. For more information
    118     about querying controller capabilities, see <a href=
    119     "http://developer.android.com/training/game-controllers/compatibility.html">Supporting
    120     Controllers Across Android Versions</a>.
    121   </li>
    122 </ul>
    123 
    124 
    125 <h3 id="back-button">Provide appropriate Back-button behavior</h3>
    126 
    127 <p>
    128   The Back button should never act as a toggle. For example, do not use it to both open and close a
    129   menu. It should only navigate backward, breadcrumb-style, through the previous screens the player
    130   has been on, for example: Game play &gt; Game pause screen &gt; Game main screen &gt; Android
    131   home screen.
    132 </p>
    133 
    134 <p>
    135   Since the Back button should only perform linear (backward) navigation, you may use the back
    136   button to leave an in-game menu (opened by a different button) and return to gameplay. For more
    137   information about design for navigation, see <a href=
    138   "http://developer.android.com/design/patterns/navigation.html">Navigation with Back and Up</a>.
    139   To learn about implementation, refer to <a href=
    140   "http://developer.android.com/training/implementing-navigation/temporal.html">Providing Proper
    141   Back Navigation</a>.
    142 </p>
    143 
    144 
    145 <h3 id="button-independence">Use appropriate buttons</h3>
    146 
    147 <p>Not all game controllers provide Start, Search, or Menu buttons. Be sure your UI does not depend
    148 upon the use of these buttons.</p>
    149 
    150 <h3 id="multiple-controllers">Handle multiple controllers</h3>
    151 
    152 <p>
    153   When multiple players are playing a game, each with his or her own controller, it is important to
    154   map each player-controller pair. For information about how to implement controller-number
    155   identification, see <a href=
    156   "http://developer.android.com/reference/android/view/InputDevice.html#getControllerNumber">Input
    157   Devices</a>.
    158 </p>
    159 
    160 
    161 <h3 id="handle-disconnect">Handle controller disconnects</h3>
    162 
    163 <p>
    164   When a controller is disconnected in the middle of gameplay, the game should pause, and a dialog
    165   should appear prompting the disconnected player to reconnect his or her controller.
    166 </p>
    167 
    168 <p>
    169   The dialog should also offer troubleshooting tips (for example, a pop-up dialog telling the
    170   player to "Check your Bluetooth connection"). For more information about implementing input-device
    171   support, see <a href=
    172   "http://developer.android.com/training/game-controllers/controller-input.html">Handling Controller
    173   Actions</a>. Specific information about Bluetooth connections is at <a href=
    174   "http://developer.android.com/guide/topics/connectivity/bluetooth.html">Bluetooth</a>.
    175 </p>
    176 
    177 
    178 <h3 id="ControllerHelp">Show controller instructions</h3>
    179 
    180 <p>If your game provides visual game control instructions, the
    181 controller image should be free of branding and include only <a
    182 href="{@docRoot}training/game-controllers/controller-input.html#button"
    183 >buttons compatible with Android</a>.</p>
    184 
    185 <p>For sample images of an Android-compatible controller, download the
    186 <a href="http://storage.googleapis.com/androiddevelopers/design/android_tv_gamepad_template-2014-10.zip"
    187 >Android TV Gamepad Template (ZIP)</a>.
    188 It includes a white controller on black background and a black controller on white background
    189 (shown in figure 1), as a PNG file and an Adobe&reg; Illustrator&reg; file.</p>
    190 
    191 <img itemprop="image" src="{@docRoot}images/games/game-controller-buttons_2x.png" width="700"
    192      srcset="{@docRoot}images/games/game-controller-buttons_2x.png 2x,
    193              {@docRoot}images/games/game-controller-buttons.png 1x" />
    194 <p class="img-caption"><b>Figure 1.</b> Example controller instructions using the
    195 <a href="http://storage.googleapis.com/androiddevelopers/design/android_tv_gamepad_template-2014-10.zip"
    196 >Android TV Gamepad Template (ZIP)</a>.
    197 
    198 
    199 
    200 
    201 <h2 id="manifest">Manifest</h2>
    202 
    203 <p>There are a some special things games should include in the Android manifest.</p>
    204 
    205 <h3 id="Launcher">Show your game on the home screen</h3>
    206 <p>
    207   The Android TV home screen displays games in a separate row from regular apps.
    208   To make your game appear in the list of games, set the
    209   <a href="{@docRoot}guide/topics/manifest/application-element.html#isGame">
    210   {@code android:isGame}</a> attribute to <code>"true"</code> in your app manifest's
    211   <a href="{@docRoot}guide/topics/manifest/application-element.html"><code>&lt;application&gt;</code>
    212   </a> tag. For example:
    213 </p>
    214 
    215 <pre class="fragment">
    216 &lt;application
    217     ...
    218     android:isGame="true"
    219     ...
    220 &gt;
    221 </pre>
    222 
    223 
    224 <h3 id="gamepad">Declare support for game controllers</h3>
    225 
    226 <p>
    227   Games controllers may not be available or active for users of a TV device. In order to properly
    228   inform users that your game supports a game controller, you must include the following entry in
    229   your app manifest:
    230 </p>
    231 
    232 <pre>
    233   &lt;uses-feature android:name="android.hardware.gamepad" android:required="false"/&gt;
    234 </pre>
    235 
    236 <p class="note">
    237   <strong>Note:</strong> When specifying {@code android:hardware:gamepad} support, do not set the
    238   {@code android:required} attribute to {@code "true"}. If you do this, users wont be able to
    239   install your app on TV devices.
    240 </p>
    241 
    242 <p>For more information about manifest entries, see
    243   <a href="{@docRoot}guide/topics/manifest/manifest-intro.html">App Manifest</a>.
    244 </p>
    245 
    246 
    247 <h2 id="gpgs">Google Play Game Services</h2>
    248 
    249 <p>
    250   If your game integrates <a
    251   href="https://developers.google.com/games/services/">Google Play Game services</a>,
    252   you should keep in mind a number of
    253   considerations pertaining to achievements, sign-in, saving games, and multiplayer play.
    254 </p>
    255 
    256 
    257 <h3 id="achievements">Achievements</h3>
    258 
    259 <p>
    260   Your game should include at least five (earnable) achievements. Only a user controlling gameplay
    261   from a supported input device should be able to earn achievements. For more information about
    262   achievements and how to implement them, see <a href=
    263   "https://developers.google.com/games/services/android/achievements">Achievements in Android</a>.
    264 </p>
    265 
    266 
    267 <h3 id="sign-in">Sign-in</h3>
    268 
    269 <p>
    270   Your game should attempt to sign the user in on launch. If the player declines sign-in several
    271   times in a row, your game should stop asking. Learn more about sign-in at <a href=
    272   "https://developers.google.com/games/services/training/signin">Implementing Sign-in on
    273   Android</a>.
    274 </p>
    275 
    276 
    277 <h3 id="saving">Saving</h3>
    278 
    279 <p>
    280   Use Google Play Services <a href=
    281   "https://developers.google.com/games/services/common/concepts/savedgames">Saved Games</a> to store
    282   your game save. Your game should bind game saves to a specific Google account, so as to be
    283   uniquely identifiable even across devices: Whether the player is using a handset or a TV, the
    284   game should be able to pull the game-save information from the same user account.
    285 </p>
    286 
    287 <p>
    288   You should also provide an option in your game's UI to allow the player to delete locally and
    289   cloud-stored data. You might put the option in the game's <code>Settings</code> screen. For
    290   specifics on implementing saved games using Play Services, see <a href=
    291   "https://developers.google.com/games/services/android/savedgames">Saved Games in Android</a>.
    292 </p>
    293 
    294 
    295 <h3 id="multiplayer-ux">Multiplayer experience</h3>
    296 
    297 <p>
    298   A game offering a multiplayer experience must allow at least two players to enter a room. For
    299   further information about multiplayer games in Android, see the <a href=
    300   "https://developers.google.com/games/services/android/realtimeMultiplayer">Real-time
    301   Multiplayer</a> and <a href="">Turn-based Multiplayer</a> documentation on the Android developer
    302   site.
    303 </p>
    304 
    305 <h3 id="exit">Exit</h3>
    306 
    307 <p>Provide a consistent and obvious UI element that lets the user exit the game gracefully. This
    308 element should be accessible with the D-pad navigation buttons. Do this instead of relying on the
    309 Home button to provide an exit, as that is not consistent nor reliable across different controllers.</p>
    310 
    311 
    312 <h2 id="web">Web</h2>
    313 
    314 <p>
    315   Do not enable web browsing in games for Android TV. Android TV does not support a web browser.
    316 </p>
    317 
    318 <p class="note">
    319   <strong>Note:</strong> You can use the {@link android.webkit.WebView} class for logins to
    320   services like Google+ and Facebook.
    321 </p>
    322 
    323 <h2 id="networking">Networking</h2>
    324 
    325 <p>Games frequently need greater bandwidth to provide optimum performance, and many users prefer
    326 ethernet to WiFi to provide that performance. Your app should check for both WiFi and ethernet
    327 connections. If your app is for TV only, you do not need to check for 3G/LTE service as you would
    328 for a mobile app.</p>
    329