Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Building Apple Watch Projects

You're reading from  Building Apple Watch Projects

Product type Book
Published in Feb 2016
Publisher Packt
ISBN-13 9781785887369
Pages 298 pages
Edition 1st Edition
Languages
Author (1):
Stuart Grimshaw Stuart Grimshaw
Profile icon Stuart Grimshaw

Table of Contents (17) Chapters

Building Apple Watch Projects
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Exploring the New Platform Hello Watch C-Quence – A Memory Game Expanding on C-Quence On Q – A Productivity App Watching the Weather Plot Buddy – All about Location Images, Animation, and Sound Wear It, Test It, Tweak It, Ship It This Is Only the Beginning Index

GameLogic


Although we have created the file GameLogic.swift file, we have not actually created the class yet (this is different to Objective C)

Create the GameLogic class

Below the import Foundation statement that is part of the template, add the following code:

import Foundation

class GameLogic {

}

Plan the class

We will create a class that will encapsulate the code that deals with the game itself in isolation from the user interface. The GameLogic class doesn't need to know anything about interactions with the user, that is something that will be taken care of by the InterfaceController class, so let's first think about what we will need it to do, so that we can start to plan which methods we will need to implement.

We need it to do the following:

  • Create and maintain a sequence of colors and add a random color to it when required

  • Evaluate whether a player's tap on a color is a correct answer

  • Provide information as to whether the game is still in play or finished

  • Clear the data that collects during...

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 $15.99/month. Cancel anytime}