Corona SDK - OUYA | Development Thread

NexusGameStudioNexusGameStudio Posts: 42Member
edited August 2013 in Corona on OUYA
We know there are quite a bit of mobile developers who use the Corona SDK to develop mobile applications in Lua, we used it ourselves to make our latest game, infinite. However, Corona has a few issues, first and foremost, the engine itself is very limiting to the non-enterprise user (which is most of all Corona users) as without the very expensive enterprise version, you cannot really adapt external API's outside that of which is supported natively by Corona itself.

That being said, Corona itself does not have native support for OUYA. While we've been trying to work with the Corona Team, their "official" support has been set on the back-burner and is not a priority. So, we're taking matters into our own hands and we're putting together code and samples to help the Corona developer get their project running on the OUYA hardware as efficiently as possible.

We hope you find this useful and if you have any special request or suggestions, ask away! We'll be updating this thread with new content or updated code as much as we can.

===========================================================
Sample Code
===========================================================

Configuration File (config.lua)
Source |
---
Notes: Configuration file to get your game displayed and scaled for HDTV's


Build Settings (build.settings)
Source |
---
Notes: Sets your Android permissions and settings (see more permissions, example given in code).


Controller Support (Code by Red Piston Games)
Source | .apk
---
Notes: Limited controller support (O, U, A, D-Pad, left analog, touchpad are supported) due to lack of external API support of Corona. All credit for this code goes to Red Piston Games who beat us to the punch ;) We compiled a .apk for your convenience.


Overscan Sample Application
(1.0)
Source | .apk
---
Notes: This is a sample application that showcases an overscan compensation tool that allows you to adjust the screen to avoid overscanning issues. The result will display information (as well as store information in the code so you can use) regarding the correct scale values. This is great to include at the very start (or options menu) of your game.

OUYA Pong (1.0)
Source | .apk
---
Notes: This is a 1 player sample of Pong in which the player can bounce the ball around the court. There are no victory conditions, nor scores. A simple demo to show how all the sample files work together (excluding the overscan demo). This demo will appear under "Games" on the OUYA.


===========================================================
Tips & Work-arounds
===========================================================

Designing Your Graphics

The problem with using Corona SDK on HDTV is that, it's designed around phone screens, so we have to trick it. Normally, you work with a base resolution of 340x480, set image suffix's in the config file and create your images at 1x, 2x or 4x resolution (depending on device). Corona would then read the screen size, check the config file to see what scale the screen lies at, then load the appropriate image set based off the resolution. This is not the case here.

When working on OUYA, Corona will not read the TV screen size, it will however, read the initial video output of the system, which is 1080p. We had a hard time trying to understand why Corona would not read 720p on the system, but it would read it on phones / tablets.

Realistically, we should be able to set our config file to 1280x720, then use suffix's to scale our images [so a scale of 1.5 (1920 / 1280 = 1.5)]. This will not work due to the issues above. So, we still set our config files to 1280x720, but we create our images to the scale of 1080p. When coding your images, even though they are made for 1080p, we set their resolution manually (using .newImageRect) at the scale of 720p. (eg. I make a banner image at the resolution of 1920x1080 in Photoshop, when I code the image, I state that it is 1280x720. Corona will automatically scale the image to whatever the TV resolution is.

Tip: When you make your images with 1080p in mind but you want to know what the resolution is for the 720p scale when you code, just take your actual image dimensions and divide it by 1.5.

=====

Editing The AndroidManifest.XML
(Get your game to appear in the 'Games' tab)

Due to the closed nature of Corona SDK, you cannot edit the Android manifest directly. There are some permission settings you can include in the build.settings file, however, the requirements for OUYA will not work there. Instead, we have to decompile our .apk file and manually add it.

1. You'll need to download the APK Manager and extract the ZIP to your desktop. This will allow us to decompile our .apk. Make sure you have the JAVA JDK already installed before any of this.

2. Open command prompt (cmd) and type 'java' (without the quotes) to initiate Java.

3. Open the APK Manager folder. If you do not see folders called "place-apk-here-for-modding", etc. Then run the Setup.bat and run option 3, this will create the folders for you. If you already have the folders, then place your Corona build .apk in the "place-apk-here-for-modding" folder.

4. Double click on Script.bat, use option 9 to decompile. This will decompile your app and place it in the folder "projects".

5. Open the "projects" folder and use your favorite editor to edit the AndroidManifest.xml. You'll want to look for the line "<intent-filter>". You should see lines below it that say:
 <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />


6. We want to add the following line below them:
<category android:name="tv.ouya.intent.category.GAME"/>

*Replace "GAME" with "APP" if you wish to appear under the Apps tab instead of Games.


It should look like this:
<intent-filter>
          <action android:name="android.intent.action.MAIN" />
          <category android:name="android.intent.category.LAUNCHER" />
          <category android:name="tv.ouya.intent.category.GAME"/>
</intent-filter>

7. Save the file and return back to the APK Manager. Select option 11 to recompile your .apk with your newly edited manifest. It will ask you if it needs to include other files, press 'n' for no.

8. Once the .apk is recompiled, select option 13 to resign the .apk with the keystore you used to make your app with.

Thats it! Your new .apk is ready and will now show up on the 'Games' tab on the OUYA system.
*Please note, this was tested with local builds, however, it should be fine to publish to app stores.*
Post edited by tgraupmann on
«1

Comments

  • Glenn_BaconGlenn_Bacon Posts: 37Member
    This is the main reason why I'm using LibGdx now.  Corona being closed and lack of support.
  • NexusGameStudioNexusGameStudio Posts: 42Member
    edited January 2013
    Updated: Added overscan sample code as well as graphics tips!

    @Glenn_Bacon

    I agree, while it's a nice tool to use and you can get stuff running pretty quick, it gets rather frustrating sometimes with either lack of particular features, depreciated docs, etc.
    Post edited by NexusGameStudio on
  • CineTekCineTek Posts: 13Member
    Wow! This is exactly what I was searching for! I do not own an Ouya yet so I tried to install my (unmodified) Android build on the Android Emulator. But it did not work as expected.

    This is awesome, but one question: In order to list my game in Ouya´s GAME section I had to modify the AndroidManifest.xml file by unpacking and repacking my .apk file. Do you have any workaround yet? :)

  • NexusGameStudioNexusGameStudio Posts: 42Member
    We'll be doing a small game sample soon, so we'll look into a correct manifest :) Currently, the Corona .apk's show up under Dev Software.
  • CineTekCineTek Posts: 13Member
    Okay, thank you :) This does really help me. Sadly, the Ouya/Killscreen challenge is over and I did not get a working prototype of my upcoming game out yet. But with this information I should be able to provide a playable build to my testers. Do you have a dev console by the way?


  • NexusGameStudioNexusGameStudio Posts: 42Member
    Sorry you did not make the deadline, wish we had a chance to get this information out sooner! We just received our dev console recently, so yes, we do have one. We've been testing all our sample files on the hardware.
  • CineTekCineTek Posts: 13Member
    It is not your fault :) This is the first time I made an Android build of my game and had some overall struggle with the simulator and so on ;)

    It is one thing to test a game on a simulator, but may I send you my (test-) build in the near future so that you can check out if it runs on a real device as well? This would be very helpful because I am not going to receive a console until April :/
  • NexusGameStudioNexusGameStudio Posts: 42Member
    Yeah for sure, just post a link or email us a .apk to nexusgamestudio [at] gmail [dot] com. Just let us know what you're looking for, etc :D
  • CineTekCineTek Posts: 13Member
    Yeah, I will do that :D

    Thanks!!!
  • NexusGameStudioNexusGameStudio Posts: 42Member
    edited January 2013
    Updated!: Included a new Pong sample game as well as tips to edit your manifest to make the game appear under the 'Games' tab.

    @Cinetek I've tried all night, sadly no work around :( Corona is wayy to closed of a platform, so they won't allow you. I however, wrote a nice tutorial to decompile your .apk edit the manifest on your Corona game to run perfectly on OUYA.
    Post edited by NexusGameStudio on
  • CineTekCineTek Posts: 13Member
    Thank you again :D. I have used the same method to decompile and repack my apk file. However, my app has been listed in the games section but due to several other problems with Android I was not able to start it. I will test your methods tomorrow!
  • NexusGameStudioNexusGameStudio Posts: 42Member
    Best of luck, if you need any assistance, we'll see what we can do :)
  • CineTekCineTek Posts: 13Member
    Okay, first of all I installed your PongSample on my virtual device but the game crashes right at the start. If it works on a real device then my virtual device must have some errors. However, I can start a little "HelloWorld" test app without any problems. So now I am going to change my config and settings files in order to get my own game running on the simulator. Does this PongSample work on your Ouya?
  • NexusGameStudioNexusGameStudio Posts: 42Member
    edited January 2013
    Yeah, every code I wrote, I made sure to test on actual hardware. The Pong sample installed and loaded perfectly:

    image

    Are you able to debug to see what in particular was causing the crash for you? Also, what method are you using to install the application?
    Post edited by NexusGameStudio on
  • CineTekCineTek Posts: 13Member
    edited January 2013
    I am using the ADB command to install my apps on the simulator. This is my error message taken from
    LogCat:

    Post edited by CineTek on
  • CineTekCineTek Posts: 13Member
    The error begins with "error opening trace file: No such file or directory"
  • NexusGameStudioNexusGameStudio Posts: 42Member
    edited January 2013
    I'll look into the issue, I was able to reinstall the app on the hardware again no problem at all (using "adb install PongSample.apk" in the command prompt). Perhaps take the source code we provided and compile it yourself on Corona and see if it will let you install it that way.
    Post edited by NexusGameStudio on
  • CineTekCineTek Posts: 13Member
    Yeah, I think the problem is related to my android simulator but I will try to compile it myself.
  • NexusGameStudioNexusGameStudio Posts: 42Member
    edited January 2013
    Updated all the .apk files to the latest Corona build, also no longer on Android dev trial (no more trial pop-ups, thanks to David @ Corona for the Pro upgrade support)

    How are things going @Cinetek? Figure out what was causing issues?
    Post edited by NexusGameStudio on
  • CineTekCineTek Posts: 13Member
    Unfortunately, I have still no idea what is going on with my virtual device. I have read that there might be some errors related to the virtual SD card that comes with each virtual device.... but I am now going to try VirtualBox and see how that works. I also upgraded to Pro in order to renew my license and to rebuild the apk files with a custom key (had Indie subscription before and used the debugkey).
    I will update this post as soon as possible :)

  • CineTekCineTek Posts: 13Member
    I have opened a new discussion for my special problem. Maybe somebody has encountered this case before (and is not related to Corona SDK)
  • cpgcpg Posts: 1Member
    ....or Corona could just open things up. Gideros doesn't have this problem. External API's - EASY. MOAI - easy. Yes, those are more advanced environments, but you have the flexibility you need. I say "easy" but, yes you will have to work at it and it will take time. 

    Effort in, effort out.
  • CineTekCineTek Posts: 13Member
    This is a possibility but I can not open the "hard-coded" games too... So that is an issue with my emulator :(
  • NexusGameStudioNexusGameStudio Posts: 42Member
    So we're looking into a new (huge) problem that we just sort of realized. Because the OUYA's business model is that the developer must make a free game, then have an unlock via IAP, I don't know if this is possible with Corona. As it stands, unless you plan on making your game fully free, there is no way (yet) to sell a paid application built with Corona.

    Working on some tests today to see if it's possible to access OUYA servers instead of Google in Corona. I'll keep you all updated.
  • NexusGameStudioNexusGameStudio Posts: 42Member
    edited February 2013
    Update on the situation:

    So unless you have the enterprise edition, there is going to be a problem. OUYA calls it's specific API to get it's IAP calls from. In Corona, you call a IAP store function then define the identifier of the product that you want it to initiate. However, this call is locked to either Google Play or iTunes App Store as it is hard-coded into the SDK itself. There are no parameters to modify to let it call OUYA.

    This is the breaking point for Corona, the inability to call the OUYA store means you cannot sell a product on the shop. You are just limited to a free title until (someday) they have official support.
    Post edited by NexusGameStudio on
  • CineTekCineTek Posts: 13Member
    It is sad to hear that there is no way to include this feature in our projects without Corona Enterprise. So I will have to wait until someone finds a workaround or Corona manages to support Ouya natively.

    Thank you for your effort in keeping us up to date :)
  • F5_ReadmoreF5_Readmore Posts: 3Member
    Is there any way to directly call the OUYA In-app purchase API through web calls? I do a lot of Web API work with Corona and if there is a way to access the Store through a Restful Web interface I could provide code to make that easy in Corona.


  • NexusGameStudioNexusGameStudio Posts: 42Member
    I do not believe so, though I cannot say for certain. Running the api's outside the app won't be able to authenticate the application since the SDK hard calls specific IAP network requests locally. Since we cannot modify the network requests in the engine, all the api calls would have to be external, not sure how well Corona plays (if at all) with that.

    Again, cannot say for certain, we don't really work with web API's so you may know some powerful magic that we don't, haha. If you're interested, it may be worth trying.
  • F5_ReadmoreF5_Readmore Posts: 3Member
    Yeah, it would probably all depend on what information we need to pull from the console to authenticate with the OUYA services. If they just need the user account information, and we could access that in Corona, it should be possible to communicate with their APIs directly. I'm sure there could be some security implications to that though if they are depending on controlling the IAP access from the console software.

    I'll try to ask one of their developers directly. We have a Corona game that we would love to bring to OUYA but if there is no way for us to process payments then it obviously doesn't make any sense.
  • ChubbRckChubbRck Posts: 11Member
    Just got my OUYA today and am hard at work porting my Corona game to OUYA - shockingly, it works pretty great right out of the box! (I downloaded it via the web browser) -

    My question is, does anyone know how to bust open the Android Manifest so I can get my game to appear on 'Games' using OSX? Many thanks - 
Sign In or Register to comment.