Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

Sparrow iOS Game Framework Beginner’s Guide
Sparrow iOS Game Framework Beginner’s Guide
Sparrow iOS Game Framework Beginner’s Guide
Ebook640 pages3 hours

Sparrow iOS Game Framework Beginner’s Guide

Rating: 0 out of 5 stars

()

Read preview

About this ebook

An easy-to-follow guide full of descriptive step-by-step procedures on how to develop a game for iOS. With each topic, a new challenge will be tackled to get a deeper knowledge of the Sparrow game framework and gain the skills to develop a complete mobile experience.
This book is aimed at those who have always wanted to create their own games for iOS devices. Perhaps you've already dabbled in game development and want to know how to develop games for the Apple App Store, or maybe you have developed Objective-C apps in the past but you are new to game development. In either case, this book will help with descriptive examples and teach you to develop a game throughout its course. Some experience in Objective-C and a basic understanding of object-oriented programming are required.
LanguageEnglish
Release dateJun 25, 2014
ISBN9781782161516
Sparrow iOS Game Framework Beginner’s Guide

Related to Sparrow iOS Game Framework Beginner’s Guide

Related ebooks

Operating Systems For You

View More

Related articles

Reviews for Sparrow iOS Game Framework Beginner’s Guide

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    Sparrow iOS Game Framework Beginner’s Guide - Johannes Stein

    Table of Contents

    Sparrow iOS Game Framework Beginner's Guide

    Credits

    About the Author

    About the Reviewers

    www.PacktPub.com

    Support files, eBooks, discount offers, and more

    Why subscribe?

    Free access for Packt account holders

    Preface

    What this book covers

    What you need for this book

    Who this book is for

    Conventions

    Time for action – heading

    What just happened?

    Pop quiz – heading

    Have a go hero – heading

    Reader feedback

    Customer support

    Downloading the example code

    Errata

    Piracy

    Questions

    1. Getting Started with Sparrow

    Understanding the basics of Sparrow

    System requirements

    Setting up the Apple developer account

    Downloading Xcode

    Downloading Sparrow

    Cloning the Git repository

    Contents of the Sparrow package

    The samples folder

    The sparrow folder

    Markdown files in the root folder

    License

    Setting up Sparrow

    Option 1 – source tree reference

    Time for action – adding Sparrow as a source tree reference

    What just happened?

    Time for action – using the barebone project as a template

    What just happened?

    Option 2 – CocoaPods

    Time for action – installing command-line tools

    What just happened?

    Time for action – installing CocoaPods

    What just happened?

    Time for action – using the barebone project as a template

    What just happened?

    Running the template on the actual device

    Time for action – running the template on the actual device

    What just happened?

    Getting Sparrow documentation files

    Time for action – adding the Sparrow API documentation to Xcode

    What just happened?

    The idea for the game

    Setting goals and expectations

    Examining our gameplay elements

    Code conventions

    Pop quiz

    Summary

    2. Displaying Our First Objects

    Understanding display objects

    Explaining display object containers

    Setting the background color

    Time for action – changing the background color

    What just happened?

    What is a stage?

    Creating our cardboard puppet doll

    Time for action – creating a cardboard puppet doll

    What just happened?

    Have a go hero – improving the cardboard puppet doll

    Explaining macros

    The Angles macro

    The Colors macro

    The utility functions

    Constants in Sparrow

    Math

    Color

    Manipulating display objects

    Time for action – manipulating display objects

    What just happened?

    Pop quiz

    Summary

    3. Managing Assets and Scenes

    Working with assets

    Managing our assets

    Time for action – creating a base class

    What just happened?

    Have a go hero

    Creating a texture manager

    Time for action – managing our textures

    What just happened?

    Creating a sound manager

    Time for action – implementing a sound manager

    What just happened?

    Creating a file manager

    Time for action – managing remaining file types

    What just happened?

    Have a go hero

    Basic error handling

    Time for action – getting started with basic error handling

    What just happened?

    Have a go hero

    Putting it all together

    Time for action – creating an asset container class

    What just happened?

    Time for action – displaying an image

    What just happened?

    Have a go hero

    What are scenes?

    Time for action – implementing a scene class

    What just happened?

    Creating a scene director

    Time for action – managing our scenes with a scene director

    What just happened?

    Have a go hero

    Pop quiz

    Summary

    4. The Basics of Our Game

    Taking care of cross-device compatibility

    Understanding the texture size limit

    How to deal with different screen sizes

    Scaling the viewport

    Black borders

    Showing non-interactive screen space

    Rearranging screen elements

    Choosing the best option

    Differences between various devices

    Utilizing the iOS SDK

    Retina and iPad support in Sparrow

    App icons and splash images

    The bottom line

    Starting with the development of our game

    Creating our scene manager setup

    Time for action – creating our scene manager setup

    What just happened?

    Adding images to the battlefield scene

    Time for action – adding images to the battlefield scene

    What just happened?

    Arranging images in the pirate cove scene

    Time for action – arranging images in the pirate cove scene

    What just happened?

    Pop quiz

    Summary

    5. Beautifying Our Game

    Working with tweens

    Time for action – moving the pirate ship

    What just happened?

    Understanding transitions

    Explaining jugglers

    Updating the movement and canceling tweens

    Time for action – updating the movement

    What just happened?

    Working with sprite sheets

    Learning about texture formats

    Using TexturePacker to create sprite sheets

    Loading our first texture atlas

    Time for action – loading our first texture atlas

    What just happened?

    Pop quiz

    Summary

    6. Adding Game Logic

    Extending the asset manager

    Time for action – adding texture atlases to the asset manager

    What just happened?

    Structuring our ships

    Time for action – creating a ship class

    What just happened?

    Extending the ship class

    Time for action – adding more functionality to the ship class

    What just happened?

    Shooting cannonballs

    Time for action – allowing the ship to shoot cannonballs

    What just happened?

    Have a go hero

    Collision detection

    Time for action – letting cannonballs collide with ships

    What just happened?

    Loading gameplay-relevant data

    Time for action – avoiding hardcoded values

    What just happened?

    Pop quiz

    Summary

    7. User Interface

    Displaying the hit points of each ship

    Time for action – placing a health bar on top of each ship

    What just happened?

    Adding buttons to the screen

    Pausing and resuming the game

    Displaying the pause and resume buttons on the screen

    Time for action – putting buttons on the screen

    What just happened?

    Implementing the logic to pause and resume the game

    Time for action – allowing the player to pause and resume

    What just happened?

    Have a go hero

    Aborting the current game

    Time for action – conceding the game

    What just happened?

    Adding dialogs to the screen

    Time for action – creating a dialog class

    What just happened?

    Have a go hero

    Adding custom events to the dialogs

    Time for action – adding our own buttons to our dialog

    What just happened?

    Drawing text on the screen

    Displaying our first text field

    Time for action – adding a text field to the dialog

    What just happened?

    Explaining system fonts

    Explaining bitmap fonts

    Creating our very own bitmap font

    Time for action – using bmGlyph to create a bitmap font

    What just happened?

    Displaying a text field with bitmap fonts

    Time for action – using our bitmap font for a text field

    What just happened?

    Pop quiz

    Summary

    8. Artificial Intelligence and Game Progression

    Artificial intelligence in theory

    Explaining fuzzy logic

    Explaining state machines

    Letting the enemy ship move and attack

    Moving the ship

    Time for action – getting the enemy ship to move around

    What just happened?

    Attacking other ships

    Time for action – the enemy should attack the player

    What just happened?

    Adding fuzzy values to the AI

    Time for action – spicing up the AI with fuzzy values

    What just happened?

    Have a go hero

    Adding progression to our game

    Adding a World class

    Time for action – adding a World class

    What just happened?

    Have a go hero

    Updating the scene and dialog classes

    Time for action – updating the scene and dialog classes

    What just happened?

    Adding game mechanics to the pirate cove

    Time for action – making the pirate cove playable

    What just happened?

    Adding progression to the game

    Have a go hero –turning our game into a real game

    Adding win and lose conditions

    Time for action – being able to win or lose

    What just happened?

    Pop quiz

    Summary

    9. Adding Audio to Our Game

    Finding music and sound

    Generating sound effects

    Learning about audio formats

    Music and sound effects for our game

    Adding audio playback

    Starting the audio engine

    Time for action – getting audio files to play

    What just happened?

    Have a go hero

    Playing music in our scenes

    Time for action – playing music in our scenes

    What just happened?

    Have a go hero

    Adding a sound effect

    Time for action – sound effects in the pirate cove

    What just happened?

    Have a go hero

    Pop quiz

    Summary

    10. Polishing Our Game

    Adding additional scenes

    The game over scene

    Creating the game over scene

    Time for action – showing the game over scene

    What just happened?

    Connecting the game over scene

    Time for action – having the game over scene show up

    What just happened?

    Adding a main menu

    Time for action – integrating the main menu into our game

    What just happened?

    Have a go hero

    Adding an intro scene

    Time for action – creating an intro for our game

    What just happened?

    Implementing tutorial mechanics

    Time for action – adding a tutorial to our intro scene

    What just happened?

    Loading and saving the current state

    Time for action – loading and saving the last played game

    What just happened?

    Pop quiz

    Summary

    11. Integrating Third-party Services

    Getting word out to potential testers

    Registering at Ubertesters

    Integrating Ubertesters

    Time for action – integrating Ubertesters

    What just happened?

    Creating a build for beta testers

    Time for action – creating a build for beta testers

    What just happened?

    Deploying an application

    Time for action – deploying an application

    What just happened?

    Explaining Game Center

    Integrating Game Center authentication

    Time for action – integrating Game Center authentication

    What just happened?

    Have a go hero

    An overview of analytics services

    Flurry analytics

    Flox

    Pop quiz

    Summary

    A. Pop Quiz Answers

    Chapter 1, Getting Started with Sparrow

    Pop quiz

    Chapter 2, Displaying Our First Objects

    Pop quiz

    Chapter 3, Managing Assets and Scenes

    Pop quiz

    Chapter 4, The Basics of Our Game

    Pop quiz

    Chapter 5, Beautifying Our Game

    Pop quiz

    Chapter 6, Adding Game Logic

    Pop quiz

    Chapter 7, User Interface

    Pop quiz

    Chapter 8, Artificial Intelligence and Game Progression

    Pop quiz

    Chapter 9, Adding Audio to Our Game

    Pop quiz

    Chapter 10, Polishing Our Game

    Pop quiz

    Chapter 11, Integrating Third-party Services

    Pop quiz

    Afterword

    Index

    Sparrow iOS Game Framework Beginner's Guide


    Sparrow iOS Game Framework Beginner's Guide

    Copyright © 2014 Packt Publishing

    All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

    Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

    Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

    First published: June 2014

    Production reference: 1180614

    Published by Packt Publishing Ltd.

    Livery Place

    35 Livery Street

    Birmingham B3 2PB, UK.

    ISBN 978-1-78216-150-9

    www.packtpub.com

    Cover image by Sujay Gawand (<sujaygawand@gmail.com>)

    Credits

    Author

    Johannes Stein

    Reviewers

    James Borden

    Alex Harrison

    Karuna Krishnasamy

    Daniel Sperl

    Sladjan Trajkovic

    Commissioning Editor

    Usha Iyer

    Acquisition Editor

    Nikhil Karkal

    Content Development Editor

    Sharvari Tawde

    Technical Editors

    Pratik More

    Ritika Singh

    Copy Editors

    Sayanee Mukherjee

    Deepa Nambiar

    Project Coordinator

    Binny K. Babu

    Proofreaders

    Simran Bhogal

    Maria Gould

    Paul Hindle

    Indexers

    Rekha Nair

    Priya Subramani

    Graphics

    Abhinash Sahu

    Production Coordinator

    Nilesh Bambardekar

    Cover Work

    Nilesh Bambardekar

    About the Author

    Johannes Stein has been interested in software and game development for most part of his life. He has used a variety of technologies, programming languages, and platforms. In the last few years, he has worked as a freelancer using web and mobile technologies for a number of different companies and start-ups, working on several iOS apps and games. Among the technologies he used were Sparrow, cocos2D, and UIKit. He has co-authored the book Irrlicht 1.7 Realtime 3D Engine Beginner's Guide that was published in 2011 by Packt Publishing. He can be followed on Twitter: @Stoney_FD.

    I would like to thank everyone who helped me in making this book a reality, specifically everyone involved at Packt for being patient with me and giving me constant and helpful feedback. My thanks go out to all the technical reviewers as well who gave me great pointers and improved the book on multiple levels. Last but not least, I would like to thank my family and friends who tried to motivate me, offering help whenever possible and getting me through a few small rough patches.

    About the Reviewers

    James Borden is an expat mobile application developer at Sotsu, Inc. in Tokyo, Japan. He has been programming professionally in a variety of languages for over 5 years now, and programming has been his hobby since he was 10 years old. He specializes in multiplatform mobile deployment, but he has experience in developing games for single platforms as well. His first mobile game was developed using the Sparrow engine. He was also featured in the book Mobile Game Engines: Interviews with Mobile Game Engine Developers, Jason Brownlee, LuLu Press, where he talks more about his experience with Sparrow. His talent is not limited to mobile development though. In his final year of college, he helped develop a 3D prototype game, utilizing a brain-computer interface as one of the game's inputs. He hopes to excel in and enjoy his profession, no matter how it changes.

    Alex Harrison is a mobile game programmer, originally from the UK. He first learned to code with Flash and ActionScript before migrating to mobile with Sparrow and eventually Starling. He is currently working on a multiplatform project in C++ and JavaScript using cocos2DX, and he develops casual mobile browser games in his spare time. Alex lives in Cape Town, South Africa, with his wife, two kids, two dogs, two rabbits, three cats, several chickens, a horse, and a pony.

    Karuna Krishnasamy is an avid gamer and a recent graduate in Computer Gaming and Animation Technology from Anglia Ruskin University. With 5 years of experience in designing and building games for the PC and iOS devices, he enjoys the process of putting a game together as much as he enjoys playing the finished product. When he isn't scoring kills in Battlefield 4 or trying to think of the next big game idea, you can find him on the paintball field, which in his words, is the best form of exercise. You can check out some of his work at http://karunaskj.com/.

    I would like to thank Johannes Stein for writing an awesome, well-written, and comprehensive beginner's guide for Sparrow. It's definitely one of my favorite frameworks, and if I had this book when I started getting into Sparrow, it definitely would have speeded up my development. I would also like to thank my family for supporting my desire to study game design and for being there to support me through many sleepless nights getting my first iOS games out in the market. Finally, I want to thank my first boss, Deepak Setty, for being an awesome mentor and role model, showing me the ins and outs of the corporate world; he is someone whom I have the utmost respect for.

    Daniel Sperl is a long-time game developer and has created numerous casual games in ActionScript, C#, and Objective-C. Unsatisfied with the existing 2D frameworks of the time, he created the Sparrow Framework for iOS, mimicking the tried and tested Flash API in Objective-C. Ironically, Adobe was looking for exactly such a framework for Flash when they introduced Stage3D in 2011, and so the Starling Framework was born. In 2012, he co-founded the company Gamua to be able to work full-time on his frameworks.

    When he is not developing Sparrow or giving support in the forum, Daniel loves to play the latest Zelda or Super Mario game with his wife or ride his bike along the countryside of Austria. He loves birds, just like his cat.

    Sladjan Trajkovic is a software engineer with a passion for game development. He has a Master's degree in Computer Science and has been working in the software industry since 2007, where he began his career as a .NET consultant.

    Nowadays, he works exclusively with the iOS platform and has been involved in several big-name applications. He has also released two games, Alien Defense Zone and Super Kicks, on the App Store as an independent developer. Currently, he is working on several new projects, both games and regular applications.

    Follow him on twitter at https://twitter.com/SladanTrajkovic.

    www.PacktPub.com

    Support files, eBooks, discount offers, and more

    You might want to visit www.PacktPub.com for support files and downloads related to your book.

    Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at for more details.

    At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

    http://PacktLib.PacktPub.com

    Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books.

    Why subscribe?

    Fully searchable across every book published by Packt

    Copy and paste, print and bookmark content

    On demand and accessible via web browser

    Free access for Packt account holders

    If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.

    Preface

    Game development is probably one of the hardest and most rewarding challenges in software development. If we are to start completely from scratch, it will take a very long time to see any results.

    With the introduction of the iPhone in 2007 and subsequent devices in the following years, developing applications for mobile devices took off, and more than 1,000,000 apps can now be downloaded from the App Store.

    Luckily, Sparrow, an open source game framework for iOS, provides us with a number of predefined classes and methods that will help in our game development process.

    Instead of showing how to develop a part of a game example-by-example during the course of the book, we will learn each stage of game development. With each chapter, our game will mature from being just an idea to a complete entity, while extending our knowledge of Sparrow.

    What this book covers

    Chapter 1, Getting Started with Sparrow, shows us how to set up Xcode, Sparrow, and our game template that

    Enjoying the preview?
    Page 1 of 1