Building Apple Watch Projects
上QQ阅读APP看书,第一时间看更新

Chapter 3. C-Quence – A Memory Game

We will be crafting an app that is a little more entertaining by using everything that we covered in Chapter 1, Exploring the New Platform, adding code which uses basic Swift features that most developers will find familiar and will address some of the topics that face the developer in creating software for a platform that presents some unique challenges.

C-Quence will be a game that challenges players' ability to memorize a sequence of colors generated by the app.

It is a game to be played in short bursts rather than prolonged activity, as one of the first things that becomes clear when using a physical device is that the watch is unsuited to tasks that take more than a short time to complete, which we will keep in mind as we look at the top-level design of the app.

Bear in mind that, although this is a very modest app in terms of the amount of coding it takes to bring it to completion, we still want to adhere to what some refer to as Best Practice (and others prefer to think of as simply learning from others' mistakes without the schadenfreude).

Here is a brief overview of how we will approach the various steps of development:

  • Plan the flow of the app
  • Set up the Xcode project
  • Build the interface in Interface Builder
  • Create the game logic class
  • Implement the Interface Controller logic
  • Hook up the classes and interface

The code presented in this chapter will reside fully on the watch, needing no support from the iPhone companion app. It will not be a complete and functioning app, that will come in the following chapter, but it will be a robust framework and we will have learned some important principles of software design.