Chapter 2. Structuring and Planning a Game Using iOS 9 Storyboards and Segues

Video game development has had an interesting history. It started as an offshoot of both electrical engineering and computer science. Games were a great challenge for engineers to make the most out of the limited hardware and, of course, make something fun. Today, video games and video game development are still built on those foundations of technology, math, and engineering but, for decades, have also been major players in the world of entertainment, storytelling, and media.

Be it if you are a major studio, a small team, or creating games all by yourself, planning and structuring your game projects can give you the foundation needed to save time in the development process, divide the work out to others if on a team, and of course, bring your game to life as close as possible to how you imagined it.

Starting with iOS 5, Apple took a page from the entertainment industry in how to structure and plan a project, big or small; by using the concept of storyboards. Storyboards are a graphic representation of the various steps and structures of a project; be it an animation, a movie, or in our case, iOS games. Storyboards will graphically show the flow of a production or app. In animation, for example, storyboards are used to flesh out major frames or story points of the production. Once it's agreed on as to what the series of events in a scene will be, animators will animate around those key points. Depending on whether the production is prelay or ADR, voice acting could also be placed into the storyboard process, which gives the animators even more specific content to work with.

In the case of the actual game application, storyboards can represent major parts of your game, such as the Intro scene, Opening Menu screen, Pause Screen, Game Over Screen, or the generic look of a main game level. Apple named these structures in Xcode storyboards, and the paths between them are known as segues. Throughout this chapter, we shall be looking into how to make use of these features while making a game app.

Structuring and Planning a Game Using iOS 9 Storyboards and Segues

The preceding is an example of a simple iOS Storyboard.

Model-View-Controller

Before we get into storyboards in iOS 9, it's best that we first discuss the basic flow of an iOS app and the concept of Model-View-Controller (MVC). Model-View-Controller is an architectural paradigm used in software engineering, programming, and even now in web design. We can think of the model portion of MVC as the logic or brains of an application's behavior. This logic is usually independent of the user interface and determines what to do with the app's data.

We've actually already gone over the model portion of MVC! The Swift programming language discussed in the previous chapter is that model; this is the case with its Objective-C predecessor and any other programming language used in iOS or any other game development. Your game's code controls what to do with the player, level, and enemy/goal data.

The view portion of MVC is the visual representation of the model. This of course would include the numerous visual aspects of our games, from our player's animation frames, various in-game stats on the HUD, particle effects, and more.

The controller portion of MVC can be thought of as the glue that holds the model and view together. It is also the point at which the user of your game interacts with. Be it actions, such as a button press, a basic touch, a swipe, or other gestures, recognized by your iOS device, the controller takes that user input, manipulates your model and then the model updates your view accordingly.

Model-View-Controller

This diagram is taken from Apple's own Adventure Game Example.

When we work with iOS apps, the first recommended entry point for code and storyboard info is the Root View Controller. As we'll come to find out, MVC is intrinsically built into iOS app development and the Xcode IDE. Storyboards are a collection of different types of view controllers with varying tasks that are linked by segues.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.172.130