Unleash your inner creativity and learn how to build great cross-platform 2D games with the popular Cocos2d-x framework If you are a game enthusiast who would like to develop and publish your own game ideas onto different app stores, this is the book for you. Some knowledge of C++ or Java is helpful but not necessary. Upgraded and updated, the powerful and popular open source framework Cocos2d-x is better than ever. Through step-by-step tutorials, you'll learn how to take complete advantage of the framework. You'll learn how to add animations and special effects, implement a physics engine, optimize your games, prepare a project for multiple devices, and develop game ideas from the test version to a finished project. Most importantly, this book provides you with the accumulated knowledge of thousands of game developers, all packed into one easy-to-use and proven framework that will save time and strenuous thinking!
http://www.packtpub.com/cocos2d-x-by-... Where to start... "Cocos2d-x by Example Beginners Guide" is a great book! Turns out one of my Appsomniacs partners has bought this book and also enjoyed its knowledge (votes+=2). Even have cut my teeth and shipped on iOS, Android and Windows 8. The Windows 8 was such a hack job I could never get it cleaned up to do a push request (I think, I should just try, at least put it in my branch. Please nag at me if I don't... It may be a bridge too many not subtle changes. Anyway, I digress, the rest of this about this great book that might help a lot of people on their Cocos2d-x journeys. ===== 1) The first thing that popped out at me when I cracked the spine on this book was the large quantity of and the technical diversity of the contributors. I was impressed with their bio/resumes and the book certainly was better for it. 2) Hang on tight. The gas pedal is binary. The book gets you up and running rather quickly. Almost too quick in some respects, but later chapters make up for that hand holding fast start in ten fold. I was worried at first a lot of bits were glossed over. Do not worry about this stuff. Great details will be given in droves, and when not a good entry point to references often sufficed. 3) I actually appreciated the section (within chapter 2) that was a primer on as well as described why the C++ was arranged the way it was (e.g., what conventions were from the Objective C world and reminders of things you need to remember to do when in C++ (i.e., proper memory management because ARC is not available.)) My favorite quote so far "... relax, and let the framework work for you." 4) The learn by example part struck me as well done. It could always cover more. I was wanton for more after 6 games. Maybe combining this and the ideas found in the iPhone Cookbook you could get even more mileage. Frankly, after you tackle this books examples. I did one a weekend (~4 hours in 1-2 sessions usually) you will be pretty well versed. The games are varied enough and the topics within cover a lot of ground. I will always want more! 5) Chapter 10 is gold for anyone coming from iOS and wanting to break into Android and really use the greatness of what Cocos2d-x brings to the table (IMO anyway.) You are presented a nice 'uncluttered' step by step walk through (albeit the compile sections was 20 steps, but they were important 'no fluff' steps! I am pleased they linked their sources on this one too. Our team put this stuff together by piecing together Android NDK posts and trial and error last year (of course we never thought to share because we never thought we did it right to begin with... it compiled... and ran, so we shipped it anyway...) I think the chapter here would have saved us much time and pain. Luckily you now have this resource to leverage. My only wish was that a little more time was spent on the tricks you have to go through to get as clean as code as possible (not special casing every piece of logic with pre-compiler directives, etc. for each platform.) Maybe a little treatise on design patterns would have been helpful here too. But I guess all of that is really beyond the scope of the book (i.e., a lifetime could be spent learning how to write well designed cross platform C++ code. If anyone knows of a good book let me know! 6) I want to mention the index. It was a basic run of the mill index. Don't get me wrong it was a good and proper index. But I can not help but note this book chapters were laid out similarly to the iPhone book "Creating Games with Cocos2d for iPhone 2", which had a brilliant index (I bet someone hated it... those darn trolls convinced them not to do it this way!) In the iPhone book most chapters covered an entire game by example much as this book did too. The iPhone version's index had a breakdown of a game chapter by game name as a sub index of concepts within it. I absolutely loved that and I dearly missed it in this one. The index is fine as it is, but having tasted the other books additional index by chapter concepts I found myself longing for it as this new book was also a perfect candidate for that format as well. But it is no reason to not get this book if the subject interests you. File this under 'I have to find something to complain about in a review' comments. ===== I do think beginning, but versed, C++ developers could pick this up and succeed if they try. If you have Objective C down C++ is not really that hard to grok also (and the parts you don't use won't likely come into play as nearly as often as you might think.) Advanced users probably won't get a lot out of it, but if you are street learned on Cocos2d like I have been (and still am learning in many respects) it wouldn't hurt to have gone over this material once. http://www.packtpub.com/cocos2d-x-by-... Thank for sticking out my wall of text this far. I am pretty sure there is an achievement for having made it this far. ;)
As with other beginner's books by this publisher, the book starts by indicating the installation process, and the proverbial "hello, world" project. The example is very trivial, but serves the important explanation of project structure, what's what in the project. Testing gets paid attention, which is nice, and then some recommendations on additional tools for sprites, textures etc. Maybe the absolute beginner can feel a little bit daunted by the amount of info to digest in the first chapter, regarding the many classes and infrastructure that you need to make a simple hello world. Luckily as the book progresses the concepts get clarified and expanded on, and that is what chapter 2 does, because obviously the hints in the chapter 1 are not enough.
I personally prefer books that explain things first rather than other books that expect you to infer things from examples. I like that Chapter 2 explains the pieces that make Cocos tick, the Containers, Nodes, Scenes, Layers, the Director, Caches etc. The author then proceeds to guiding the unexperienced developer to a basic understanding of C++ Classes, header files and all, explaining almost every line, and finishes off by bridging the differences between C++ developers and Cocos2D developers so they are familiar with the common ground offered by the framework.
Without further ado, Chapter 3 sees us create the first game, where we finally start to see some action by adding resources, preloading sounds, targeting retina displays, extending CCSprite, and even adding multitouch. It's nice because a functional game is created step by step. One also realizes that game dev is relatively complex even when it's a simple game. The book again follows the way of showing the code and then proceeding to explain it line by line. Chapter 4, builds on the previous chapter to build now a different, more complex game. We're not just stuck to simple examples.
Chapter 5 continues wit this dynamic, building a different game, this time about rockets, this time introducing some particle physics, as the next level of complexity in your games.
Chapter 6. Different game. The twist comes with the introduction of testing and rapid prototyping using placeholders with the Cocos2D platform. The author now reveals this is how he created every example in the book. Abundant screenshots and lots of code accompany here. I think the chapter is well placed. You've followed how to code a couple of simple games, then you're shown some "secrets" and techniques for testing your ideas before investing lots. After the prototyping, chapter 7 actually builds the game with the real graphics, so you get the whole picture from concept testing to actual implementation.
Chapter 8 introduces Box2D, for adding realistic physics, that would be way too much effort to do on your own. Project creation is a breeze, but you got to take account of the differences between coding a game with Cocos and with Box (different classes, basically). It can look simplistic, in the sense that even when using a game library, a lot of tweaking for the right values of trajectories, where to place things, etc must be done.
Chapter 9 rounds off our game coding by introducing ancillary aspects, like reading/writing data, scenes, transitions, etc, which not being vital, are things every game needs. For me the game in this "level" ;-) is the funniest, but I am a platform buff. Notifications, via the observer pattern, are introduced too. Using the accelerometer in the device.
Chapter 10 closes the book by paying attention to what used to be a hell for me ten years ago when doing games for the j2me platform: portability. You get warned and then led to creating different projects for different devices / platforms and some additional tools. Appendix A then gives you some vector course 101 if you were a bit weak in that aspect.
Needless to say, a book like this is code-intensive, otherwise it would not be much worth. You could say that it reads as a series of tutorials of increasing complexity, the main chapters being self contained in this sense, which is good if you want to complete chapters one by one in easy sittings.
The games cannot be complex production pieces, that would exceed any book's scope, but I think they are enough to motivate you to start coding some game of your own. In that sense, the book gives you a more than adequate basis. For sure, if you not only read the book but take the trouble to type and make some changes of your own to the book, you will no doubt spend quite some hours engrossed with learning all this stuff. Be sure to check the code download, full of comments not present in the book for obvious reasons. All in all, I'd say the book in this case is more than a beginner's guide. Nobody becomes a master of anything with just one book, but this one sets you off handsomely.
Excellent book for iOS -- light on other platforms
If you’ve been luxuriating in the joy of developing games iOS-centrically the last few years, it’s a pretty good bet you’ve been using cocos2d-iphone. And it’s also a pretty good bet that the pressures are mounting to acknowledge the existence of other, lesser, platforms. The path of least resistance to that is to go with the cocos2d-x fork adopted as part of the cocos2d coordinated releases. But up until now there’s been a substantial dearth of documentation for that option, which the good folk at Packt have now remedied!
The first chapter runs through getting you set up and doing the Hello World thing on a Mac with Xcode with the 2.0.4 version, which is the last stable release before the book’s publication date, just in time to be superseded by the 2.1.3 release, although the differences are pretty trivial; and recommends for your tool suite that you pick up Texture Packer, Particle Designer, Glyph Designer, and cfxr. Which are good choices across the board.
Chapter 2 goes over the basic structure of the cocos2d framework, introduces C++ to the native iPhone developer and discusses how to live without ARC, or conversely for the C++ programmer how to live with the root class paradigm. Not sure you’d ever manage to square that circle to anyone’s complete satisfaction, but what’s here is a good attempt.
Chapters 3 through 9 go through a series of mini-game examples, introducing
- images (including retina), sounds, sprites, multitouch, bounding collisions - sprite sheets, bitmap fonts, background music, actions, universal apps - particles, drawing primitives, vector math - placeholder prototyping, terrain generation, platformed collisions - texturing terrain, parallax, sprite nesting, menu and tutorial modes - Box2D physics worlds, bodies, controls, and collisions - scenes, transitions, data loading and saving, notifications, accelerometer
That’s one solid amount of stuff to cover in a beginner’s guide! Plus there’s a very nice appendix on introductory vector math applications, nice touch there. And these games are rather polished for tutorial examples. Indeed, the first criticism of the book is that they’re not up on the App Store for you to check out yourself what you’d be learning, which you may recall we thought was a pretty compelling feature of the Creating Games with cocos2d book. But hey, you can see screenshots on the author’s blog here.
Chapter 10 — “Code Once. Retire.” — yep, that’s what most of you are probably here for … and it’s a bit of a disappointment. It covers how to set up an Android “Hello World” project skeleton with Eclipse, and some arrangements for hybrid Android/Mac compilation … and that’s pretty much it. For the intended audience, that's rather a flaw. What would make this a five-star book is if all the samples were available on the iOS App Store, as grumbled about last paragraph, but also on the stores for at least three or four of the platforms cocos2d-x targets, and discussion in the book of just what was involved in customizing the code, assets, and deployment tactics for each.
So, depends what kind of “beginner” you are how valuable you’ll find this.
“Beginner” to cocos2d from scratch? Easy five stars, buy it now.
“Beginner” to cocos2d-x with an oeuvre of cocos2d-iphone code you want to get shipped on other platforms? Useful, but just barely gets you started on anything but porting your Objective-C to C++ code, which chances are you could do on your own if you’ve ever programmed anywhere but the iPhone. If you do have a solid C++ history and at least nodding familiarity with Android project setup, three stars; if not, four stars.
So overall it deserves a solid four stars; some more followthrough on deploying the examples onto non-iOS platforms, and it would unquestionably get five stars.
Cocos2D-X stands as a great way to switch from single-platform to multi-platform game development. This great framework effectively allows developers to maintain a single codebase while publishing to a huge number of platforms. Although it is as great as it sounds, the amount of information available on how to learn/use it is scarce, to say the least.
This book - Cocos2d-X by Example Beginner's Guide - presents itself as THE way for experienced Cocos2d-iPhone developers to make the switch to multi-platform development, by using the Cocos2d-X framework. It accomplishes that feat by introducing the basics of the C++ programming language and explaining how you can apply your knowledge of Cocos2d to build great multi-platform games. It follows a step-by-step approach and provides detailed explanations on how to effectively transition from the Objective-C"-centric" Cocos2d-iPhone to the C++"-based" Cocos2d-X.
Throughout this book, you'll build five (somewhat complex) little games that will allow you to learn how to use texture atlases, handle animations, create parallax layers, handle physics and particles, among other essential tasks.
As it stands, this is the best Cocos2d-X resource I've encountered. It's aimed at experienced developers with knowledge of Cocos2d-iPhone, but I believe that it's actually pretty easy for an inexperienced programmer to gather some useful information from this book. The way that the author presents the information is clear and concise. He rarely misses important facts/info and even offers some extra tidbits of useful information along the way.
I came across a few inconsistencies and errors throughout the book, mainly in the code's formatting. A few times, the code examples mentioned variables that were presented with slightly different names within the Xcode project. Although that can be somewhat distracting, I was able to overcome these few hurdles with ease, mainly thanks to the way that the author clearly explains how everything works.
I'm giving it 4 stars instead of 5 due to the rare inconsistencies in the code formatting and also because the author assumes the developer is working on a Mac. It's understandable, due to the fact that this is aimed at the Cocos2d-iPhone developer. However, seeing as Cocos2d-X is a multi-platform framework, it would've been great to see a few instructions on how to setup and build projects on other platforms. Although the author does explain how to build for Android through Eclipse, he misses out on explaining how to create a Cocos2d-X project in Visual Studio and/or how to build an application for OS X or Windows.
Overall, it's a really great book for anyone interested in moving to multi-platform development by using one of the most popular game development frameworks available. It stands as the ultimate resource for learning how to develop games with Cocos2d-X and it's definitely a must-buy for anyone interested in doing so.
A great book to start learning cocos2d-x, its method of working on a small game for each chapter is very effective and quickly boosts your motivation. The example projects are perfectly lined up to teach you the basics first, and then work your way up discovering all the features needed for a cross platform 2d game. All the code samples worked for me with almost no headaches.
The only drawback I found at first was that the book tackles the 2nd version of cocos2d-x at times where the current stable one is v3.2. I found it almost impossible to work with the latest version of the framework, that's why I chose to go back to the latest available release from the v2 branch which is v2.2.5. That made the samples work with minimal tweaking, mostly just a few lines here and there (this blog post from the author helped in this regard: http://rengelbert.com/blog/cocos2d-x-... )
The author works with a Mac and XCode, which didn't make my task easier, but I quickly found the way to make a new project and integrate the code from the book's samples thanks to a few google searches (hint: %Cocos2dFolder%\tools\project-creator\create_project.py)
- The code is quickly out of date, due to Cocos2d-x changing frequently. - At times there are large changes you must make if you're following along, so if you make a mistake you don't necessarily get feedback until you've typed a lot. At that point you have to go through your changes slowly. - At other times the code is pretty poor - possibly because the author is trying to introduce cocos2d-x concepts and is not worried about code quality. It even shows signs of copy paste (the author does not always put the * in pointers in the same spot - C++ programmers are nuts about that).
The Good:
- Going through several games it not only works as a tutorial but also a reference. - This is the first time I've really understood cocos concepts, despite reading a few books on it. - Is fun! - Also the only book on cocos2d-x
I'd recommend it to a learner, but you should also be looking at the test code in the Cocos2d-x distribution.
The Book Cocos2d-x by Example offers really great way to start diving into the world of multiplatform programming and portability. Cocos 2D-X is a must if you really want to reach customers on all major mobile platforms. And this book is the excellent point to start switching to portability. The book is well-structured and designed to be great comprehensive guide on this road. Its full of examples and formatted nicely, to be do-it-yourself guide If you're Objective C developer planning to switch to C++ and multiplatform development, you'll find everything you need to know about Cocos 2d-x here. Here's the link http://www.packtpub.com/cocos2d-x-by-...