Cocos2d 2.0, iOS 6 & iPhone 5 Updates

Hey all. I’m proud to announce that the iOS Game Creation for Beginners and the Action RPG Engine kits have now been updated for iOS 6 and are using Cocos2d iPhone 2.0.0!

Cocos2d 2.0

Cocos2d 2.0 is packed with a whole bunch of new features, fixes and other goodies. Of particular note is that it now uses OpenGL ES 2.0, which enables the use of shaders. Basically, shaders allow you to write a bit of code which runs on the GPU and executes rendering effects. There’s a lot of cool stuff you can do with shaders, like embossing, waving grass, luminosity and rippling water.

The last version of our RPG engine required the use of the GL_GREATER glAlphaFunc() to render sprites correctly in the z order when using a 2D projection and the vertexZ property for z ordering. CCSprite was subclassed and the draw method was overridden:

@implementation CCZSprite
	-(void) draw
	{
		glEnable(GL_ALPHA_TEST);
		glAlphaFunc(GL_GREATER, 0.0f);
		[super draw];
		glDisable(GL_ALPHA_TEST);
	}
@end

Since the new RPG engine uses Cocos2d 2.0, we can use a shader:

[self setShaderProgram:[[CCShaderCache sharedShaderCache]
	programForKey:kCCShader_PositionTextureColorAlphaTest]];

iOS 6

iOS 6 packs over 200 new features into the iPhone, iPad and iPod touch operating system, but the biggest news for game developers is the announcement of the iPhone 5 with it’s 4 inch retina screen. This adds another screen ratio to the list:

  • iPhone 4S – 960×640 – 3×2 ratio
  • iPad – 1024×768 – 4×3 ratio
  • iPhone 5 – 1136×640 – 16×9 ratio

 
When developing universal apps, we’ve now got to keep this new ratio in mind and test our games to make sure they look right. If you’ve already got the iOS Game Creation for Beginners or RPG engine kits, you’ll already be familiar with how to develop universal apps for any screen resolution.

Zero Warnings

Our RPG engine has a cool feature which automatically creates HD versions of TMX tiled maps on the fly. This enables you to draw and maintain only a single SD version of each level map. At runtime, the game automatically uses HD art resources and increases all the positions and tile dimensions appropriately.

This auto-HD parsing was done by overriding CCTMXMapInfo with a category, essentially replacing a few methods (parseXMLFile: and parser:didStartElement:namespaceURI:qualifiedName:attributes:). This worked, but in Xcode 4.4 it started generating some compiler warnings. In Xcode 4.5, there’s a new linker warning as well.

We overcame the warnings and both the Beginners and RPG Engine kits now compile perfectly cleanly, with zero warnings. The old method of overriding CCTMXMapInfo with a category has been replaced with method swizzling. It’s a fun phrase to talk about, and not that difficult to implement. With method swizzling, we basically tell the instantiated CCTMXMapInfo object to use different methods:

method_exchangeImplementations(
	class_getInstanceMethod(self, @selector(parseXMLFile:)),
	class_getInstanceMethod(self, @selector(autoParseXMLFile:)));

 

Dpad vs Touch Switch

The RPG engine has always allowed a player to use either touch-based movement or the Dpad. With this newest release of the engine, we've added a switch to RPGEngine.h to allow you to specify the default movement method. Just set kRPGDpadMovementIsDefault to 1 if you want to use the Dpad by default.

iPad Retina Graphics

The Monster Checkers game included in the iOS Game Creation for Beginners kit now has a set of iPad 3 retina graphics, so you can see how to develop a game with three tiers of art assets.

Cocos2d 2.0 has a new method of automatically loading the correct art assets which makes our old chooseResource method obsolete. Instead of doing this:

CCSprite* bg = [[CCSprite alloc] initWithFile:[KITApp chooseResource:@"main-menu.png"]];

You can now just do this:

CCSprite* bg = [[CCSprite alloc] initWithFile:@"main-menu.png"];

Cocos2d will load the appropriate art resource, whether it's the SD, HD or HDR (HD Retina) version. Just make sure you've set up your suffix preferences. Here's how we like to do it, which re-uses the same graphics for iPhone retina and iPad non-retina, to conserve space in the app's overall download size:

// setup our file suffixes for high-res artwork
CCFileUtils* fileUtils = [CCFileUtils sharedFileUtils];
[fileUtils setiPhoneRetinaDisplaySuffix:@"-hd"];
[fileUtils setiPadSuffix:@"-hd"];
[fileUtils setiPadRetinaDisplaySuffix:@"-hdr"];

 

Misc

The books included in the kits have been updated and the Beginners kit now features a Spritesheets folder, which contains the all the individual sprite files for the Monster Checkers game and the Texture Packer (.tps) files to create the sprite sheets.

We hope you enjoy all the new benefits of the 6.0.0 releases of our kits. Download them now. Just login and click the Downloads link. If you have any troubles, check out this forum post or write us in the comments.

Happy coding.

  • Diogo Dantas

    I bought the iOS Game Creation for Beginners some month ago and i learn a lot from it. But what happens now that this new version is released? Do i have to buy it again?

    • Nat Weiss

      @Diogo: You get lifetime updates for free. :) Just register on this site and make sure to use the same email you used to purchase with. Then click the main Downloads link. That’s it. If you run into any snags, check out this forum post about how to get your download links.

  • Diogo Dantas

    Thank you very much Nat!! I just downloaded my copy without problems :)

  • carl.last

    Always impressed how quickly you turn these around. Thanks.
    A really useful purchase.

  • syasgoor

    Hi Nat,
    Want to create a game, I’m hoping somewhat on the simple side, similar to the concept of Word War. Does you iphone game creation include directions for creating this type of game

    • Nat Weiss

      Hi, iOS Game Creation for Beginners will teach you how to make a very similar game, checkers. It also has a whole chapter about how to plan your own game.

  • Vladimir

    hi! is it possible to get your email to contact ?

    • Nat Weiss

      Vladimir, yes, it’s at the bottom of the page.

  • -->

    Featured Posts


    Hero Bash: the party moba!

    iOS 7 + Cocos2d 2.1 Update

    Making Cross-Platform iPhone & Android Games – Don’t Get Left Behind! (Part 3)

    Recent Posts


    Tuning the Mind

    From Programmer To Artist 10 of 10 – The Beginning

    From Programmer To Artist 9 of 10 – Animation

    The Ultimate Cocos2d-x Platformer Engine

    A cross-platform, parallaxing game engine based on cocos2dx. Includes procedural level generation, scripting, dynamic texturing, realtime multiplayer, virtual economy (in-app purchase) and all the basics like moving platforms, boxes, slopes, water, ladders and artificial intelligence. Write your game code in C++ and level scripts in Javascript. Games built with this kit can be deployed to iOS, Mac, Windows, Android and any of the other platforms supported by cocos2d-x.
    More Info...


    Action-RPG Engine Code & Tutorial

    Create your own RPG, RTS, action or adventure game with this source kit. Learn how to manage tilemaps, characters, AI and more. This kit includes a flexible RPG engine built on cocos2d iphone (now called cocos2d swift), along with a sample RPG project called Quexlor Lite. Also included is a PDF ebook tutorial and bonus royalty-free art package. Written in Objective C, games built with this kit can be deployed to iPhone, iPad and iPod Touch.
    More Info...


    iPhone Game Creation for Beginners

    This game source kit is a hands-on introduction to making games for the absolute beginner. No programming experience is required. The included PDF book walks you through all the basics of how to code with Objective C and will familiarize you with the tools you need to develop an iPhone game. It includes source code and Xcode project files to a simple checkers game built with cocos2d iphone (now cocos2d swift). Also included is documentation, a game template project, support and a bonus artwork package to start your own creation. Games built with this kit can be deployed to iPhone, iPad and iPod Touch.
    More Info...