Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Ouya Unity Game Development

You're reading from  Ouya Unity Game Development

Product type Book
Published in Oct 2013
Publisher Packt
ISBN-13 9781783559701
Pages 118 pages
Edition 1st Edition
Languages
Author (1):
Gary Riches Gary Riches
Profile icon Gary Riches

Mobile controls


We're going to keep our controls really simple for this demo, there won't be a virtual joystick or button in sight. As we only need three functions, namely left, forward, and right, we'll be breaking the screen up in to three sections and using the left section for turning left, the center section for forward, and the right section for turning right. The following is a screenshot of the game with the control areas overlaid for illustration purposes:

We already have our control script for the game, Sokoban, so go ahead and double-click on it to edit it in MonoDevelop.

We're going to create a new method that will return true or false when we pass it in a string for the control direction we want to check. It should only return true if the tap has just happened, and not keep returning true if the user holds his finger on the screen. The method is as follows:

  // Check if an area of the screen has been
  // touched for the very first time
  bool FirstTouchForControlType(string controlType...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}