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.
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?