New Cocos2d-x tutorial series

Hello all,

I’d just like to announce that I am working on a Cocos2d-x tutorial series over on Although to be honest, “series” is a bit of an exaggeration at this point, as right now there is only one part available. Obviously more are in the works. I had previously created a (rather outdated now) Cocos2d-HTML tutorial series and I would expect this series to end up somewhat similar, although probably a bit longer.

I am working with the most current release ( 3.3beta0) in an attempt to be as timely as possible, and hopefully future proof things a bit. Right now the first part is up, covering installation, creating a project and a Hello World. It also introduces the reader to important concepts, such as Cocos’s memory management.

The next part(s) should be available shortly. I hope these prove useful to people. Also, if you spot a mistake I’ve made, or have a suggestion, I would certainly love to hear it! Basically as long as people keep reading them.

EDIT – Added Basic Sprites, Positioning, Parenting and Coordinate Systems

EDIT – Added Handling Mouse and Touch Input

EDIT – Added Handling Keyboard Events

EDIT – Added GameLoop, Updates and Actions


Cool, thanks for making this available to the community.

Thanks for the tutorial!

A few things I would change:

  • Currently, v2.X is not “less actively developed”: cocos2d-x team clearly said they won’t touch at all (save perhaps a few very important fix, like Heartbleed). See For how long Cocos2Dx 2.x is going to be supported?
  • Current stable verison is 3.2, not 3.0
  • I have heard several report of NDK 10 not working very well. Did you get it to work? Otherwise I would include a warning about using it.

Other than that, my suggestions are to show the use of cocos command to build project before showing the IDE way (seriously, it’s great, doing a build in one step is part of the Joel test), and to explain a bit more the reference counting, or link to an external source explaining it. Lots of people are confused with that.

You write great tutorials, that’s good news :slight_smile:

Thank you for the feedback.

I fixed the 3.2/3.0 error and made an edit in regards to 2.x being unsupported.

Do you have a link regarding to NDK10? I don’t recall running into trouble, but I worked on two different systems, one running 9 and one running 10, so I am not sure which I tested on. I suppose I should test this myself.

I figured I would be talking about memory management a bit later on, so I would go into greater detail later. Didn’t want to overload people with the gritty details in the very first post, but figured the memory management issue was big enough that I should address it upfront.

I agree and disagree about command line builds. On the one hand, as a developer I certainly appreciate it. When new to a library though, it does have a wif of the black magic about it, which is why I went the IDE route first. I should refactor it so the command line option is better highlighted though.

Thanks for the feedback, much appreciated.

Thanks a ton, I love hearing stuff like that. :slight_smile:

About NDK 10, I don’t have a proper link. A saw one or two posts about people having problem on the forum, and the recommended fix was to get back to NDK 9. I also had a talk with an Intel dev last week, who told me about the same thing: NDK 10 (the first versions at least) are broken, Google know it and is going to fix it (the current available version might be good, I didn’t try myself).

For the command line build, on the other hand I think it’s cool you can just run a command and get everything built and installed on your device without doing anything. I would just add a few lines before presenting the IDE. But that’s your tutorial, not mine :slight_smile:

NDK 10 problems

Thanks, edited to reflect.

Loved it,
especially the line

"a singleton is a delayed, but guaranteed to be instantiated global variable in a pretty dress. "

We also have hundreds of free video tutorials for Cocos2d-x and Cocos2d-JS

I added the next part in the tutorial series, Basic Sprites, Positioning, Parenting and Coordinate Systems. Once again, any and all feedback appreciated.

Hopefully with the fundamentals covered, future tutorials can start becoming a bit more hands on. I hope some of you are finding these useful or amusing. I also updated the (very small) Table of Contents, as well as adding navigation links and top and bottom of the posts… granted, kinda ugly nav, but nav none the less.

Great. I like written tutorials more than videos - you can easily skip to the part you are interested in. Also please do some more advanced stuff. There are many tutorials about basic stuff but what I would like to see is something about networking,lua scripting and how to properly hook them up, custom shaders etc :wink:

1 Like

I hope to cover, well, basically everything as time goes on. Or at least the stuff you need for 95% of games. Obviously I have to nail the foundations first though.

Who wants a 4pics 1Word tutorial? :smile:

Added another part, Handling Touch and Mouse Input

It covers, drum roll please… handling mouse and touch input. Specifically touch, multitouch and mouse events.

Next part up. Handling the Keyboard.

It covers how to implement a keyboard listener, how to work with the soft keyboard on mobile as well as implementing a simple solution making it possible to poll for keyboard state.

you are correct ! :smile:

and by 95% used by games , i hope you meant:

-in-app purchase
-posting a screenshot of your gamescreen/score to your Facebook wall
-G+/FB log-ins

:smile: awesome!

1 Like

I can certainly see covering some of those topics, although I will generally stick to topics that are parts of, or achievable with, the core framework.

That is the catch with a lot of those topics, take for example Facebook or Twitter integration. I have done this in other languages/libraries, and unless you have out of the box support, it’s not really something that is appropriate for a tutorial. You have to make a network request, do an oauth2 handshake ( this is where you lose most people ), then parse the response data and format your requests accordingly. It’s not overly difficult, but it’s exceedingly difficult to do in tutorial form. What I would end up doing in fact is writing a library to do Facebook integration and then writing a tutorial about how to use my library. This is the kind of stuff I will avoid covering.

What I could however see covering is making network requests from Cocos2d-x. This knowledge in turn could be applied by someone wanting to write a Facebook or Twitter integration library. It sort of falls under the whole “give a man a fish vs teach a man to fish” argument.

Make sense?

Hey, I am happy that people like you are helping beginners like us and around to learn such a praiseworthy framework.

I don’t know if I am expecting too much or I am harsh but if you wish to consider my suggestion then here it is:

There are already tutorials by sonarsystems which teaches sprites positioning, handling and other basic thing…
So, in future or whenever you make tutorials please contribute towards portions which are not covered anywhere so that we don’t have less repeated topics…

Anyways I like your work so far although I had to learn these things either by asking in forums or by reading documentation and all. Because written tutorials like what you’re aiming for aren’t anywhere except few new books so it would go far :smiley:

All the best and thanks