Coronasdk Creating ANDROIDTV Apps

Source: Internet
Author: User

First, download the https://www.dropbox.com/s/h8s5v2xrtpkhpb3/AndroidTVTutorial.zip?dl=0 source directory here.

The directory can be found Rgeasyftv.lua, open can see below corresponds to the Android TV game controller (remote control? ) button's code:

--Android TV Code Mappingsif(ONFTV) Thencodes[ +] =' up'codes[ -] =' Down'codes[ +] =' Left'codes[ A] =' Right'codes[4] =' Back'codes[ the] ='Menu'codes[ the] ='a'codes[ the] ='b'codes[ About] ='x'codes[ -] ='y'

Since this mapping has been done for you, you only need to refer to the code by name, for example: KeyName = = ' a '.

In the build.setting file, you need to set SUPPORTSTV to true, and isgame to true. This SUPPORTSTV setting makes your app adaptable to Android TV. If you don't add this setting, your app can still be submitted to Google Play, but it won't show up on your customer's Android TV device.

In the Screen1.lua file, you can see the following code:

Local functionOnftvkey (Event)if(Enablelistener = =false) Then return false End    LocalKeyName =Event.keynameif(Event.phase = ="began") Then    ElseIf(Event.phase = ="ended") Then        if(KeyName = ='a')or(KeyName = =' Right') ThenonScreen2 ()End    End    return trueEndListen ("Onftvkey", Onftvkey)

This is an Android TV game controller to control the application of the code, you can see here is mainly for a direction key and a key. Another benefit of the Rgeasyftv.lua file is that you can test your app by using your computer's keyboard instead of the game controller during your development period.

There are two other important things:

1 You need to include a 320x180 banner-xhdpi.png file in your app.

21 What you need to provide when adding apps to Google Play how your app works on TV.

Once the event code used to receive the game control input is written, you can create an app for Google Play.

Next, use your developer cable to connect your Android TV and your PC with USB to make sure the connection is up and running. On your MacBook, we drag the exported androidtvtutorial.apk to Android->sdk->platform-tools.

In the console, we change the directory to Platform-tools, locate our adroid TV device, and then install androidtvtutorial.apk in.

At this point, your app can run on Android TV.

Coronasdk Create Androidtv app

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.