Setup
Tutorials
API
Guidelines
Game Engines
Construct 2 Engine
Downloads
Open source, clone https://github.com/ouya/ouya-sdk-examples/tree/master/Construct2
Forums
@OUYA - (Construct 2 on OUYA Forums) - http://forums.ouya.tv/categories/construct2-on-ouya
@Construct 2 - (Forums) - https://www.scirra.com/forum/
Getting Started
Intro to Construct 2 (19:40)
|
Resources
Construct 2 - https://www.scirra.com/construct2
Supported Platforms - https://www.scirra.com/manual/168/supported-platforms
Construct 2
Construct 2 is an visually programable engine that publishes HTML5.
Setup
Windows
Install Construct 2.
Install your license file into the
C:\Program Files\Construct 2\folder.Install the
Construct 2plugin changes and the OuyaSDK plugins into yourConstruct 2plugin folder.Restart Construct 2
Publishing
Publishing to the OUYA requires that you package the generated HTML from Construct 2 into an Android wrapper, preferrably using the WebArchive prebuilt configuration from the HTML5 docs. The WebArchive prebuilt configuration provides accelerated WebGL and accelerated video decoding.
Use the menu
File->Export project...itemSelect
HTML5 websiteand clickNextbuttonSpecify the
HTML5output folder and clickNextbuttonSelect
Normal styleand click theExportbuttonZip the
HTML5output into a single zip file.Rename the zip file to
web_archive.jarMove
web_archive.jarinto the WebArchiveres/rawfolderCustomize the package name in
ContentShell/AndroidManifest.xmlCustomize the app name in 'ContentShell/res/values/string.xml`
Repackage the WebArchive and run on the OUYA using the available WebArchive scripts
Setup
Before you can use the OuyaSDK be sure to create a game in the developer portal and download the signing key.
The IAP example places the signing key in ouya-sdk-examples\Construct2\InAppPurchases\customization\assets\key.der which gets packaged when running ouya-sdk-examples\Construct2\InAppPurchases\package.cmd after exporting HTML5 to ouya-sdk-examples\Construct2\InAppPurchases\Build.
Testing
You won't be charged when making IAP purchases of your own game.
Be sure to log into the OUYA with the same developer account that the game is created for in the developer portal.
You can reverse purchases in the purchase page of the developer portal to test refund scenarios or testing first-time purchases.
Look for the View and remove your purchases of your products link on the bottom of the purchase page to refund purchases of your own game.
OuyaSDK API
To access the OUYA SDK, insert an OuyaSDK object into your layout.
The OuyaSDK object has to be in the layout for the OuyaSDK events to fire.
Right click the Layout and select Insert New Object.
Select OuyaSDK and click Insert.
Initialize the OUYA Plugin
Interacting with the OUYA SDK can be done via the event sheet.
Start of Layout
Add an event System\On start of layout.
Add actions addInitOuyaPluginValues and initOuyaPlugin to the On start of layout event.
Developer UUID
The Developer UUID is available in the developer portal.
You must be logged in to see your Developer UUID.
addInitOuyaPluginValues
addInitOuyaPluginValues has key and value arguments.
Add a key of "tv.ouya.developer_id".
Add a value using your Developer UUID.
The initOuyaPlugin action will invoke initializing the OUYA Plugin given the values added with addInitOuyaPluginValues.
Init Events
Initialize OUYA Plugin on Success will be invoked if the OUYA Plugin was initialized.
Initialize OUYA Plugin on Failure will be invoked if the OUYA Plugin failed to initialize.
After initializing the OUYA Plugin the other IAP actions can be invoked.
Actions can be added to the init events.
The onFailure event provides error code and error message fields.
OuyaSDK.errorCodeOnFailureInitOuyaPlugin- The failureerror codeas a numberOuyaSDK.errorMessageOnFailureInitOuyaPlugin- The failureerror messageas a string
Xiaomi Initialization
addInitOuyaPluginValues supports additional strings to make the game compatible with OUYA Everywhere devices.
tv.ouya.developer_id- The developer UUID can be found in the developer portal after logging in.com.xiaomi.app_id- The Xiaomi App Id is provided by the content team, emailofficehours@ouya.tvto obtain your key.com.xiaomi.app_key- The Xiaomi App Key is provided by the content team, emailofficehours@ouya.tvto obtain your key.tv.ouya.product_id_list- The product id list is a comma separated list of product ids that can be purchased in the game.
Request Gamer Info
The gamer info includes the gamer's username and unique identifier. Add an OuyaSDK\Request Gamer Info action.
Request Gamer Info has 3 events for on Success, on Failure, and on Cancel.
The Gamer Info fields are available in the onSuccess event.
OuyaSDK.GamerInfoUsername returns the string for the gamer's username which can be used to display in a Text object.
OuyaSDK.GamerInfoUuid returns the string for the gamer's unique identifier.
The onFailure event provides error code and error message fields.
OuyaSDK.errorCodeOnFailureRequestGamerInfo- The failureerror codeas a numberOuyaSDK.errorMessageOnFailureRequestGamerInfo- The failureerror messageas a string
Request Products
Requesting products gets the details about the Product created in the developer portal.
{
"currencyCode": "USD",
"originalPrice": 2.99,
"localPrice": 2.99,
"description": "",
"name": "Sharp Axe",
"developerName": "Sample Developer",
"identifier": "sharp_axe",
"percentOff": 0
}
Add the action OuyaSDK\Request Products.
Request Products takes a string which is a comma separated list of product ids.
You can pass a comma separated list "a,b,c,d,e,f" or a single product "my_awesome_sauce".
The IAP example waits for a button press before invoking the Request Products action.

Request Products has 3 events for on Success, on Failure, and on Cancel.
Request Products on Success gets a list of product details.
OuyaSDK.ProductsLength returns the count of products returned.
Retrieving product details uses an index from 0 to (OuyaSDK.ProductsLength - 1).
Create a global ProductIndex used to get the product details.
Use the Set action to set the ProductIndex to start at the beginning of the products list.
Add a Repeat event to iterate over each of the returned products.
The count will be OuyaSDK.ProductsLength times.
All the OuyaSDK.GetProducts* accessors take the ProductIndex to return the Product item's details.
OuyaSDK.GetProductsIdentifier(ProductIndex) - Returns a string of the product identifier
OuyaSDK.GetProductsName(ProductIndex) - Returns a string of the product name
OuyaSDK.GetProductsDescription(ProductIndex) - Returns a string of the product description
OuyaSDK.GetProductsLocalPrice(ProductIndex) returns a float for the local price of the product.
Increment the ProductIndex with a Set action after looking up the data for each product.
The onFailure event provides error code and error message fields.
OuyaSDK.errorCodeOnFailureRequestProducts- The failureerror codeas a numberOuyaSDK.errorMessageOnFailureRequestProducts- The failureerror messageas a string
Request Purchase
Requesting a purchase requires the Product entitlement or consumable was created in the developer portal.
Add the action OuyaSDK\Request Purchase.
Request Purchase has 3 events for on Success, on Failure, and on Cancel.
The onFailure event provides error code and error message fields.
OuyaSDK.errorCodeOnFailureRequestPurchase- The failureerror codeas a numberOuyaSDK.errorMessageOnFailureRequestPurchase- The failureerror messageas a string
Request Receipts
A receipt indicates that the gamer has purchased your entitlement.
After querying the receipts list, iterate through the items to check if your entitlement product_id is found to unlock the full game or feature.
{
"gamer": "2927b3d9-e940-077a-8f68-af923f52f5d9",
"uuid": "be05dfcdc4eb0d50",
"generatedDate": "Thu Jan 01 00:00:00 GMT 1970",
"localPrice": 0.99,
"identifier": "cool_level",
"currency": "USD",
"purchaseDate": "Tue Nov 11 01:36:12 GMT 2014"
}
Add the action OuyaSDK\Request Receipts.
Request Receipts has 3 events for on Success, on Failure, and on Cancel.
Request Receipts on Success gets a list of receipt details. OuyaSDK.ReceiptsLength returns the count of receipts returned.
Retrieving receipts details uses an index from 0 to (OuyaSDK.ReceiptsLength - 1). Create a global ReceiptIndex used to get the receipt details.
Use the Set action to set the ReceiptIndex to start at the beginning of the receipts list.
Add a Repeat event to iterate over each of the returned receipts.
The count will be OuyaSDK.ReceiptsLength times.
All the OuyaSDK.GetReceipts* accessors take the ReceiptIndex to return the Receipt item's details.
OuyaSDK.GetReceiptsIdentifier(ReceiptIndex) - Returns a string of the product identifier
OuyaSDK.GetReceiptsGeneratedDate(ReceiptIndex) - Returns a string of the generated date
OuyaSDK.GetReceiptsLocalPrice(ReceiptIndex) returns a float for the local price of the receipt.
Increment the ReceiptIndex with a Set action after looking up the data for each product.
The onFailure event provides error code and error message fields.
OuyaSDK.errorCodeOnFailureRequestReceipts- The failureerror codeas a numberOuyaSDK.errorMessageOnFailureRequestReceipts- The failureerror messageas a string
Set Safe Area
Add the action OuyaSDK\Set Safe Area.
The IAP example uses a floating-point SafeAreaAmount global variable that adjusts the safe area amount.
The Set Safe Area action takes a SafeAreaAmount floating-point number. Safe area amounts range from 0.0 with full border to 1.0 with border.
Set Safe Area has 2 events for on Success, and on Failure.
The onFailure event provides error code and error message fields.
OuyaSDK.errorCodeOnFailureSetSafeArea- The failureerror codeas a numberOuyaSDK.errorMessageOnFailureSetSafeArea- The failureerror messageas a string
Shutdown
Add the action OuyaSDK\Shutdown.
Shutdown has 2 events for on Success, and on Failure.
The onFailure event provides error code and error message fields.
OuyaSDK.errorCodeOnFailureShutdown- The failureerror codeas a numberOuyaSDK.errorMessageOnFailureShutdown- The failureerror messageas a string
Examples
The examples are capx files which are complete projects that depend on installing the OuyaSDK Construct 2 plugin.
Virtual Controller
The Virtual Controller example shows 4 images of the OUYA Controller which moves axises and highlights buttons when the physical controller is manipulated. The Virtual Controller example includes support for OUYA-Everywhere.
Open the VirtualController.capx from the Construct 2 SDK examples.
In-App-Purchases
The In-App-Purchases example shows making purchases, checking receipts, adjusting the safe area, and exiting the app.
Open the InAppPurchases.capx from the Construct 2 SDK examples.








































