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
About the Author
About the Reviewers

Time for action – checking high scores in a new scene

The first thing we need is a way to store the high score whenever the level ends. This means we'll need to get the number of cannonballs fired at the end of a round and create a PlayerPrefs entry for it. We'll do this by creating a static function to return the total number of cannonballs fired in the script and calling it from the target whenever it's hit. The steps to do so are as follows:

  1. Create a new static function called GetCannonballCount in the ScoreKeeper class, and add a line that returns the integer value of numCannonballsFired, as shown in the following code:

    public static int GetCannonballCount()
      return numCannonballsFired;
  2. Open your TargetScript file, and add the following lines to its OnCollisionEnter function to save the player's score, which we'll access later from the high score script:

    void OnCollisionEnter(Collision collidingObj)
      gameObject.renderer.material.color =;