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