viernes, 30 de agosto de 2013

Excellent Cocos2D tutorial

Hi all!

Yesterday I completed a great tutorial that guides you in a step-by-step basis to complete a simple iPhone game using Cocos2d. You can find the tutorial here.

Note that Cocos2d is not ARC-compliant (ARC stands for Automatic Reference Counting and you can check here for very interesting information about it), but in this post, it is explained how to make the Cocos2d Xcode templates ARC-compliant. Even when the library does not use ARC, you can of course develop any game using ARC-compliant code.

Happy coding!

jueves, 29 de agosto de 2013

Towards Game Development in iOS

I've been curious for a long time about how to program for iPhone and iPad (in general, for iOS) and about Objective-C, the language under which to develop for this operating system, so I finally decided yesterday that it was time to delve a little bit into the details of this programming language. 

If you can program in C/C++ and you know the fundamentals of Object-Oriented programming (knowing Java also helps), the leap to Objective-C seems pretty straightforward. I started reading the book Learning Objective-C 2.0: A Hands-on Guide to Objective-C for Mac and iOS by Robert Clair. I found this book very illustrative and well-written, so I can openly advice it. 

Objective-C is an extension to plain C and very often it presents subtle differences with C++, such as the fact that you cannot create objects in the stack (i.e. you must always hold pointers to objects allocated in the heap), there's no syntax support for abstract classes, there are some new reserved keywords like nil (a pointer to no object) and id (a pointer to an object of any class), etc. 

Possibly, the biggest change is that of the 'messaging system' used in place of function calls or method invocation. In Objective-C, you use the syntax [receiver message] where receiver is an object of a class and the message is the name of a method of that object. Technically, it seems another way of the same idea of method invocation, but the difference comes from the fact that this statement is not resolved  at compile time but at run-time, adding more flexibility. Of course you can nest expressions and the result would be used in the next level (e.g. [[receiver message] message] would first evaluate the inner [receiver message] part and then the result would be used as the receiver of the outer [receiver message]).

The book also shows you how this messaging system (and other high level stuff) works under the hood (in the end, all is translated into plain C) and how to bypass the runtime (the runtime translates from Objective-C to plain C and fills in certain structures with class information) to gain efficiency when required, given that a function call, if very simple, is more than twice faster than the receiver-message scheme.

Regarding memory management, the language traditionally required the developer to manually take care of releasing allocated memory or retaining it, using manual reference counting. However, Apple included recently Automatic Reference Counting, which means that the runtime is in charge of doing this dirty work in an efficient way. In fact, Apple encourages developers to use this feature as it can give an important performance boost to applications and prevent memory leaks. 

I've read more than half of the book and I'm enjoying it. My goal is to be able to develop games for iPhone and iPad, probably using existing and reputable frameworks such as Cocos2D. If your goal is the same, I highly advice you to learn the fundamentals of Objective-C and I think that this book is a perfect starting point.

See you!

lunes, 26 de agosto de 2013

Ludum Dare or how to force yourself to complete a game quickly

If you have a game already developed or almost completed, you may be interested in participating in Ludum Dare competition. As I told you in an earlier post, this competition consists of creating a game (or several of them) as fast as possible. If you check their web page, you will see that there's a countdown that will reach zero in around seven hours. So what are you doing reading this post?? Hurry up!!

Back to game development after holidays!

Hi all!

It's been a while since the last post, but I've been first busy and then on holidays. However, I'm back and I'm  more eager than never to continue developing my game and sharing my experiences with you.

Don't miss the upcoming posts, which include further discussions on integration (see here and here for more information), parallax scrolling (see here) and some early images of the game I'm working on (check here and here), together with a general description of the small engine that supports the game.

Keep playing!