How to Use - Rado-1/ZgeOuya GitHub Wiki
Important: this page is applicable for the latest version of the library, compatibility to the previous versions is not guaranteed.
Usage of OUYA IAP in ZGameEditor project
Important: To use the OUYA IAP functionality in your application, you should be an registered OUYA developer and should create game(s) and product(s) to purchase. More information about how to become OUYA developer can be found here.
Since all IAP functionality includes Internet communication with OUYA backend server, it is realized by asynchronous request-response communication pattern. The common call pattern is used:
- Include
ZExternalLibrary
component for ZgeOuya library to theOnLoaded
section ofZApplication
. It can be found in the context menu Add from library... > External libraries > OUYA library of the Project tree. - Initialize IAP with
ouya_InitPurchasing()
. This call is usually placed to theOnLoaded
section ofZApplication
orOnStart
section ofAppState
component. You must provide your developer UUID downloaded from the OUYA Developer Portal. - In order to request the OUYA server, first, the
ouya_Request*()
function is called to initialize communication. This call can be placed at any position in your code where appropriate. - Then, the
ouya_Is*RequestDone()
is used to check the availability of the response. If this function returnsouya_YES
, the response is available and you can read the result. If the function returnsouya_NO
the request is still in progress. If theouya_ERROR
was returned, the request failed and the outputerrorMsg
parameter contains the error message. Theouya_Is*RequestDone()
function is usually called inOnUpdate
section ofZApplication
,AppState
, orModel
components. - When the response is available, the results can be read by the
ouya_Get*()
function. - To close the IAP processing, call the
ouya_StopPurchasing()
function. This call is usually placed to theOnClose
section ofZApplication
,OnLeave
section ofAppState
, orOnRemove
section of theModel
component respectively.
Note: the previous description uses *
as a placeholder for the type of requested object; it can be "Purchase" for purchasing a product, "Receipts" for a list of already purchased products, and "GamerInfo" for information about the current gamer.
Important: Android package name of your game, as specified on the OUYA Development Portal, must be identical to the ZApplication.AndroidPackageName
property. If not, your game cannot perform purchases or obtain purchase receipts; the "Invalid game Uuid was provided" error is returned.
Examples of usage ZgeOuya IAP in ZGE can be found at the download page.
Usage of OUYA Controller in ZGameEditor project
- Put the
Android Gamepad Library
ZLibrary to theOnLoaded
section ofZApplication
. It can be found in the context menu Add from library... > Libraries > Android Gamepad Library of the Project tree. - Ask for status of the controller buttons with
joyGetButton()
function and status of the joystick axis with thejoyGetAxis()
functions. These functions are usually called fromOnUpdate
section ofZApplication
,AppState
, orModel
components. - To identify OUYA buttons and axes, use the
OUYA_*
codes defined in the library.
Video about how to add OUYA Controller to an existing ZGE project:
Building application for OUYA IAP
- Set the ZApplication.AndroidSdk to "4.1 (API Level 16)".
- Compile your Android application, e.g., use Project / Android: Build APK (debug) menu item.
- Download the OUYA Development Kit form this link, extract it, and the included
ouya-sdk.jar
file place to thelibs
folder of your application. - Place
libZgeOuya.so
file to thelibs/armeabi
folder. - Place the
ZgeOuya.java
file to thesrc/org/zgameeditor
folder. - Place the game signing key file
key.der
(obtained from the OUYA Developer Portal) to theassets
folder. - Compile the APK again as in step 1.
- Deploy the APK file to your OUYA device and install it. You can use, for instance, USB transfer from PC to OUYA and FilePwn OUYA application for installing the application at the device.
Note 1: Seps from 1 to 6 are required only when the application is built the first time. After that, a single compilation produces the correct APK.
Note 2: Use steps 4 and 5 also in the case when updating to a newer version of the ZgeOuya library.
Building application for OUYA Controller, without usage of IAP
To build your application just to support OUYA controller, without making use of the IAP mechanism, perform the steps 1, 2, and 8 from the process described in the previous section.