How to go from view to view in iOS

This might seem like a very simple and easy thing to some of you out there. However I have failed to see any clear and concise explanation of how to do it. So here it goes:

  1. Create a segue from from the blue controller to the red controller. You do this by hovering over the icon pictured below, and then clicking and dragging while holding the ctrl button, until your over the view controller you want to navigate to.
  2. You will be presented with the option below, and for this blog post just pick “show”. Then the following arrow below will be created, this is called a segue. Set the name of the segue to something descriptive, in this case I am going to be naming it “ToRed”.
  3. Create a button on the blue view controller, and create a IB action for that button. Then inside the method call the “performSegue(withIdentifier: “ToRed”, sender: nil)” method where the “withIdentifier” is the name of the segue you want to use to do the navigation.
  4. Now create a button on the red view controller and create an IB action for that button. However this time inside the method call the “dismiss(animated: true, completion: nil)”. This method allows you to go back to your previous view.

And thats all there is to it. Next time I think I am going to be getting into the topic of passing data back and forth from views, which requires an understanding of protocols and delegates.

You can find the link to the final product here.

The Best Brick Breaker Game Ever

Recently I have started to learn how to use the Unity game engine. The more I learn about about game creation and development, the more I realize that it is the ultimate form of self expression. A game is as much of a piece of art as the a painting is, and takes much more time to create.

So in the pursuit of learning more about Unity to make more interesting complex games. I have decided to make as the title suggests “The Best Brick Breaker Game Ever”. As they say “you learn more by doing”. I choose this genre of game because, it hasn’t gotten any love and attention since arcades were still a thing.

Understanding Unity – Part 2

The primary language of Unity is C#, but you can also use JS and Boo (python). Most of the tutorials and assets out there use C#. In my opinion C# is just like JAVA so if you know that you should be just fine. When you create a script in Unity it automatically inherits from the class MonoBehaviour. If you do not inherit from MonoBehaviour your class becomes a regular old C# class.

MonoBehaviours have a number of methods that you can implement, that are called over the life time of the object. All the way from when the object first gets created to when it is destroyed.

These different methods are executed in a different stages and these stages happen in a certain order. Going from “Initialization” -> “Game Logic” -> “Decommissioning”. I am not including a few of the stages here because they are not fundamental for getting started with unity.

Then the break down of the most important methods in each stage would be as follows:

  • Initialization:
    • Awake()
      • This function is called the second that an object is created. “Created” in these sense just means the second that game engine acknowledges its existence.
    • Start()
      • Similar to Awake() this function is called right before the first frame that is being rendered. You can think of it like just before it appears on screen.
  • GameLogic:
    • Update()
      • The Update function holds all your game logic, and gets executed every frame
  • Decommissioning:
    • OnDestroy()
      • The OnDestory function gets called just before a object is destroyed. This can come in handy, when you want to say update the score after killing an enemy.

There are also event triggered functions, such as OnCollisionEnter2D that get executed under specific situations. In the next post I will go over these functions, and the 2D physics system in Unity.


Understanding Unity – Part 1


Unity is one of the most popular and easily accessible game engines to date. Which has lead it to become of the best documented and beginner friendly games engines. It can be used to create both 2D and 3D games, and uses C# as it’s main scripting language. And the best part is that every part of it is completely free. Combined with its robust asset store and plethora of free online tutorials it is the game engine to learn these days.

How Unity Works:

To understand Unity, you need to first understand the differences between a library and a engine. A library is something to that you use to build your application, whereas a engine is something that only calls your code.

Unity is an engine, it is something that you have to understand and use in your pursuit to make a game. You do not get to decide on how the physics engine works or how the lighting effects work. You are just given a number of ways to use the sub systems that were created for you.

When you create anything in unity your making a object. Every object in unity has certain properties attached to it, like its position and scale. You can add other components to it like a particle emitter or sprite render. The way you start coding your game is by way of using scripts that you attach to the object like any other component. Once the script is attached you can then start manipulating the different attributes your game object has.

In the second part of this series I am going to talk about the life cycle of a unity object.