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 – capturing data with return values


What's on the outside of your functions matters just as much as what's on the inside. Optimizing the amount of information passed around between functions ensures that you'll never find a bridge that you can't code across. Perform the following steps to capture data:

  1. Move your function call from the Update function back to the Start function and reset the translation value to 2.0f. For learning purposes, imagine that your Start function needs to know how far the MoveObject function moved the text to the right. We already know that the movement value is a float, so we can change the return type from void to float. Your function should now look like the one shown in the following code:

    float MoveObject ()
    {
      gameObject.transform.Translate(2.0f, 0.0f, 0.0f);	
    }

    Tip

    At this point, the MoveObject function will cause an error because nothing is explicitly returned in the function body. Using a return type in a function necessitates a return, so...