Book Image

OUYA Game Development by Example

By : John Donovan
Book Image

OUYA Game Development by Example

By: John Donovan

Overview of this book

The OUYA console and development kit gives you the power to publish video games for the players, creating a console marketplace of the gamers, for the gamers, and by the gamers. Using the OUYA developer kit and the Unity3D game engine, even beginners with a captivating game idea can bring it to life with a hint of imagination. OUYA Game Development by Example uses a series of feature-based, step-by-step tutorials that teach beginners how to integrate essential elements into a game engine and then combine them to form a polished gaming experience.
Table of Contents (18 chapters)
OUYA Game Development by Example Beginner's Guide
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – creating your first purchase function


The first step when integrating purchases is to mark any script that manages purchasing as a purchase listener. This tells the OUYA SDK that it will be handling at least one transaction and needs to be able to access the product list. Perform the following steps to create a function for purchasing:

  1. Add the following lines of code to your class definition to enable it to listen for all IAP activity:

    public class PauseScreen :   MonoBehavior,
                                 OuyaSDK.IPauseListener,
                                 OuyaSDK.IResumeListener,
                                 OuyaSDK.IFetchGamerInfoListener,
                                 OuyaSDK.IGetProductsListener,
                                 OuyaSDK.IPurchaseListener,
                                 OuyaSDK.IGetReceiptsListener
    {
      ...
    }
  2. Add the following extension to your PauseScreen script's Awake function to mark it as a listener for all of the previous events:

    void Awake ()
    {
      OuyaSDK...