Diary of my experience developing a Tic Tac toe game in Swift (part 1)

I’ve never developed a Swift application in iOs before but I thought it would be fun to spend some time rapidly developing a Tic Tac Toe game and document my experience.

My first step is find out how to setup an ios environment. This part was easy as I had previously had to setup Xcode in order to get the developer tools installed on my machine.

Swift Playground

Swift has a really cool playground which was really interesting. I plan on playing in the playground later on to learn more about the language.

From the Apple iOS documentation
“A playground is an interactive Swift coding environment that evaluates each statement and displays results as updates are made, without the need to create a project.”

Setting up the project

I delved right into it by creating a “Single View Application” iOs project. Single View application because the game will only have a single view. Seeing as this simple rapid developed application won’t be doing any persistant saving. We won’t be using core data.

Once the Project is created, I jumped into the properties of the file and made sure that the device orientation for the app stays in Portrait mode, adding support for Landscape will add to the complexity.

I wanted to remove auto layout and this one is just a preference, in my small experience with autoLayout, I found it to be too intrusive.

Image assets

We need image assets which will be our Markers and the lines that represent the grid.

When creating new image sets, I had to be mindful of the various sizes, in order to support the different resolutions that are on the many iOs devices out there.

This being rapid development, I quickly mocked out two grids jpegs in Photoshop.

grid_320_569.jpg
grid_640_1138.jpg

Adding Image as Background

To add the background image asset. I created a UIImageView and placed it on top the first View that the user will see the moment they launch the application.

Adding clickable images

To add clickable images we first create 9 clickable image views then we add 9 buttons that overlay those images. These buttons will later be attached to IBActions.

Next up we will can begin plumbing, adding the images,buttons, views to the respective code. I’ll cover that in a separate blog post.

 


Ced

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s