O'Reilly logo

Cocos2d Cross-Platform Game Development Cookbook - Second Edition by Siddharth Shekar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing Cocos2d Swift

Now that you have a basic understanding of the Swift language, let's take a look at how it is used in Cocos2d.

Getting ready

Creating a Cocos2d-Swift project is very easy. While creating a project, you have to specify the language used as Swift instead of Obj-C while creating a project using SpriteBuilder, as follows:

Getting ready

How to do it…

You will see that the project structure is different now. Instead of the MainScene.h and MainScene.m files, we just have a MainScene.swift file.

Now, to load the MainScene.swift file, we have to make some changes to the AppDelegate.m file, just as we did for Obj-C projects.

In the AppDelegate.m file, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required