Learn to program games for iOS: getting to know Xcode

how to program games for iOS

I debut in Actualidad iPhone with a series of educational content posts: I'll teach you how to program iOS games in Xcode; always, from a close, easy point of view, and avoiding technicalities, so that anyone with a desire can create games for Apple devices. I myself have published my latest game a few days ago, Lite Fish.

This series of posts are dedicated to people familiar with computers, but without special programming notions; In short, and especially in the first steps, anyone can follow it. We will touch on some basic aspects of Xcode, and later, we will use Cocos2D to create very simple games.

I learned to program games exactly one year ago, just having basic web design ideas; so anyone in a similar situation can do it! You only need a Mac (since Xcode, the tool used, can only run on Apple's operating system), really want to, and lose your fear of so much computer code!

To begin with, we will talk about Apple's developer program: to make applications for iOS, you do not need to pay any fees, just download Xcode and the iOS SDK. This will allow us to experiment; But if the time comes, we want our work of art to appear in the App Store, there yes, we will have to pay 80 Euros to acquire an official license and be able to do so.

With that said, let's download xcode from the Apple website, or from the Mac App Store. Its installation is simple, you just have to run the file that we have downloaded and wait (It may be necessary to register if you choose the first download option, but it is free).

Once installed, we open it, and we create a new project. (Fillet>new>project).

From among all the options, we choose the one we see in the image:

Program Games: Template Selection in Xcode

It is a simple application with a single window. Next we enter a name for our application, and a company identifier (something like the license plate of your game, which makes it identifiable to Xcode). You can put anything. Pay attention to the boxes that you have to check or uncheck:

Program Games: Name Selection

By giving the following, we see the structure that xcode shows when creating a project:

Xcode main screen

  • Above, a series of controls that will allow us to run the application in order to test it on the computer and see how it would appear on the iPhone / iPod.
  • On the left are the files that make up our application.
  • In the center are the options of our application. We see that we can change the version, choose if we want it to be for iPod / iPhone or Universal, or even the orientation of the application. For now, we leave everything as is.
  • On the right, Xcode shows us options that we'll explore later.

Going back to the left panel, we take a look at the classes or files that we see inside the test folder. We see that each one has two versions with the same name: one ending in ".h", and the other ending in ".m".

In the ".m" is the content itself, the code, so to speak; while the others, for now we do not need.
AppDelegate it is the file that always runs first when the application starts. Always, without exception. In any application. It contains necessary information, such as which windows should be loaded, or what to do when starting. If we enter AppDelegate.m, we will see that in a certain place, it names «ViewController«.

Schedule iOS Games: AppDelegate.m File View

This means that in our case, view controller is the name of the file or "window" that will be displayed when the application is started, once the AppDelegate file has finished reading. It can be called in any way, but by default, that is the name it has taken.

Since this tutorial is an introduction to Xcode, when creating the project we used a template that generates a first and only scene "with graphical help"; that is, a third file viewcontroller.xib(in addition to the versions viewcontroller.m and the viewcontroller.h that we had talked about), that we can edit graphically without using lines of code, which facilitates the creation of applications.

So, we click with the mouse on viewcontroller.xib (the graphical version of our initial file, viewcontroller), and drag an object «label»From the panel found at the bottom right (you have to find it from among all the components that this panel contains):

Viewcontroller graphical interface

Once done, we double click on that label object, and put the text we want. Right after, we looked up at the button play that we find in the upper part of the program, and we press it with the mouse; As we can see, the "iPhone Simulator" has been chosen, so we can guess that we are going to test the application on a virtual iPhone ...

Programming iOS Games: Xcode Simulator

This is what appears! You already have your first application. When you want to close it, click the button Stop.

I hope that, although you do not understand the why of many things, you have become familiar with Xcode. Its structure, its application simulator, etc.

In the following lessons, we will talk about Cocos2D; a different template from the one we have used in this example, which we will install in our xcode, and which will allow us to program games in a relatively simple way, with less code than would be needed if we did not have it!

More information - Lite Fish

Download - Xcode


How to rename apps on iOS and iPadOS
You are interested in:
How to rename iPhone apps
Follow us on Google News

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: AB Internet Networks 2008 SL
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Alfred said

    Phenomenal

  2.   djdared said

    Great article!!

  3.   Marco said

    The initiative was very good, I tried to get on with it but I left it, to see if now I can get hooked.

  4.   July said

    Thanks for the article! ... hopefully many more will come

  5.   Eduardo Way said

    Great, I was looking forward to something like that!

  6.   Anthony Villagran said

    Great, how often will you keep putting articles like this.

  7.   J. Ignacio Videla said

    Good article, I am a programmer of PC and Android games, the truth seems to me your initiative is good, I have always wanted to launch myself on iOS, maybe, just maybe, some day, I will launch xcode for windows and there the doors will open for the poor like me xD

    1.    paco rr said

      you can buy mac os x and install it on a pc, it is very easy to search online

      1.    J. Ignacio Videla said

        I believe you, but first, if it really worked well, I doubt that mac would be sold as they are sold ... and I'm not just saying it because of the cost of the computer, but also the high cost of publishing in the app store, which compared to other platforms It is very high.

        1.    David said

          Actually I second the opinion of paco, I write you from a hackintosh, look for the versions of iatkos it is very easy to install, I have not used windows for a long time

          1.    David said

            Many people do not change because of that same fear and the crazy ideas that they have been dragging along.

  8.   Miguel Mathus said

    Congratulations on your initiative Sergio

  9.   anton said

    Thank you very much, all very clear for a first contact, I liked it a lot and I already have a thousand ideas in mind ... I hope you cheer up and keep getting such good articles.

  10.   Fernando Sanchez said

    Excellent !, I hope you continue and do not stay with these tutorials halfway like many.

  11.   Sergio April said

    Thank you all very much, I'm glad you liked it! I will try to contribute everything in my power in the following entries, and I hope you find them just as interesting :)!

    1.    sh4rk said

      Before jumping into the pool with cocos2d-iphone, I would consider starting the tutorials on cocosbuilder 3.0 and cocos2d-js directly, it seems that there is the immediate future, and more in Spain, which is the kingdom of Android and it is a good idea to remove cross-platform things.

      I take this opportunity for those of you who are going to follow these tutorials to take a look at http://www.raywenderlich.com, there is tons of very useful information on many topics in iPhone programming, games included.

      By the way, congratulations on the game 🙂

    2.    Rachel said

      Hello, we are a group of university students whose work project is to develop a very simple app on a specific topic. We have really liked your publications, even so we are a little lost on the subject because we have never done it before. Could we get in touch privately to see our possibilities? Thanks 🙂

  12.   xsolutions said

    Man with searching a little one realizes that it is not necessary a mac to use osx with the scene iaktos

    Returning to the topic Very good article and good initiative most xcode manuals are in English and difficult you should think about publishing a manual in apple ibook store

  13.   Fernando Alone said

    I think it's a great idea!!! keep it up !!!

  14.   lalex said

    I encourage you like many not to stop publishing this course and I will be one of your faithful by coming to class

  15.   nope said

    Bravo, congratulations on the initiative.

  16.   jovijano said

    I just bought a second-hand Mac mini, just to learn how to program for IOS, I have already downloaded many books in Spanish and soon I will start to try to handle Xcode, I thank you very much for the initiative and I will be a regular follower of yours.
    Thank you…

  17.   kikobeats said

    I want more !!

  18.   Fernando Hdez said

    Good work, good article, although I have a question
    Is there a way to program but for windows some other program?

    1.    Cristian Diujenio D. said

      For IOS, and actually for any mobile platform, there is Adobe Flex and Air, Frameworks that allow the development of applications. It is the only solution I have found to generate something for apple mobiles from windows. Or raise virtual machines with mac os x, to be able to raise xcode, although I do not recommend it, because it is a real pain. Far, it is preferable to invest in a mac, if your focus is the applications in IOS.

  19.   eduardo aldaz said

    Help me with the next lesson to continue with this excellent contribution? Thank you..