Cocos2d-X by Example Beginner's Guide

Cocos2d-X by Example Beginner's Guide

Roger Engelbert

Language: English

Pages: 246

ISBN: 178216734X

Format: PDF / Kindle (mobi) / ePub

Cocos2d-X by Example Beginner's Guide

Roger Engelbert

Language: English

Pages: 246

ISBN: 178216734X

Format: PDF / Kindle (mobi) / ePub


With Cocos2d-x you don’t have to be a programming whiz to be a genius at game design. This tutorial will help unleash your inner creativity with lots of fun tutorials. Get the know-how to build great cross-platform 2D games.

Overview

  • Learn to build multi-device games in simple, easy steps, letting the framework do all the heavy lifting
  • Spice things up in your games with easy to apply animations, particle effects, and physics simulation
  • Quickly implement and test your own gameplay ideas, with an eye for optimization and portability
  • Enjoy building the games as much as you will enjoy playing them

In Detail

Cocos2d-x is the C++ port of arguably the most popular open source 2D framework in the world. Its predecessor was limited to the Apple family but with Cocos2d-x you can take your applications to all major app stores, with minimum extra work. Give your games a larger target audience with almost no extra hassle.

"Cocos2d-X by Example Beginner's Guide" allows you to build your own cross platform games using all the benefits of a time tested framework, plus the elegance and simplicity of C++.

Each of the six games developed in this book will take you further on the road to becoming an expert game developer with no fuss and plenty of fun.

Follow six tutorials for six very different games that leverage the ease of Cocos2D-X and its quick implementation, moving from simple ideas to more advanced topics in game development.

In easy-to-follow steps, the book teaches you how to take full advantage of the framework by adding animations and special effects, implementing a physics engine, and optimizing your games.

Prepare your project for multiple platforms and learn how to take your game concepts to completion.

"Cocos2d-X by Example Beginner's Guide" will present to you, in six different games, the topics necessary to build some of the most popular and fun types of games today.

What you will learn from this book

  • Make your games look cooler with particle effects
  • Create place holder sprites to quickly test your game ideas
  • Load external data into your games
  • Build game menus and tutorials
  • Implement game-wide events with notifications
  • Create a dash game with a textured terrain
  • Build a Box2D puzzle game with multiple levels
  • Create a hybrid iOS and Android project

Approach

Get to grips with Cocos2D-X using step-by-step examples. Roger Engelbert will have you smiling throughout and learning valuable information at every turn.

Who this book is written for

If you have brilliant ideas for amazing games and want to bring them to life, then this book is what you need. Work through easy-to-follow examples and learn exactly what you need to know to make your games a reality. No programming experience necessary!

Amazon Web Services: Migrating your .NET Enterprise Application

C++ Primer (5th Edition)

MongoDB Cookbook (2nd Edition)

Building Web Applications with Erlang: Working with REST and Web Sockets on Yaws

Agile Software Architecture: Aligning Agile Processes and Software Architectures

 

 

 

 

 

 

 

 

 

 

 

 

 

0.5, _screenSize.height * 0.5 + 2 * _ball->radius())); } else { _player2Score++; sprintf(score_buffer,"%i", _player2Score); _player2ScoreLabel->setString(score_buffer); _ball->setNextPosition(ccp(_screenSize.width * 0.5, _screenSize.height * 0.5 - 2 * _ball->radius())); } The players are moved to their original position and their _touch properties are cleared: _player1->setPosition(ccp(_screenSize.width * 0.5, _player1->radius() * 2)); _player2->setPosition(ccp(_screenSize.width * 0.5,

wrapping the CCRotateTo action. CCRotateTo takes 1.2 seconds to rotate the sprite first to -10 degrees and then to 10. And the easing has a value of 2, which I suggest you experiment with to get a sense of what it means visually. Next we add three more actions: //action sequence for shockwave: fade out, callback when //done _shockwaveSequence = CCSequence::create( CCFadeOut::create(1.0f), CCCallFunc::create (this, callfunc_selector(GameLayer::shockwaveDone)), NULL); _shockwaveSequence->retain();

if (_pauseBtn->boundingBox().containsPoint(tap)) { _paused->setVisible(true); _state = kGamePaused; _pauseBtn>setDisplayFrame(CCSpriteFrameCache: :sharedSpriteFrameCache()->spriteFrameByName ("btn_pause_on.png")); _running = false; return; } } 8. If so, we change the game state to kGamePaused, change the texture on the _pauseBtn sprite (by retrieving another sprite frame from CCSpriteFrameCache), stop running the game (by pausing it), and return from the function. 9. We can finally make

pTouches, CCEvent* event) { if (!_running) { if (_player->getState() == kPlayerDying) { _terrain->reset(); _player->reset(); resetGame(); } return; } [ 126 ] Chapter 6 If we are not running the game and the _player object died, we reset the game on the next touch. 2. Next, if the terrain has not started: if (!_terrain->getStartTerrain()) { _terrain->setStartTerrain ( true ); return; } Remember that at first the buildings are all the same height and there are no gaps. Once the player

autorelease/retain is recreated here. So for instance a Player class, which extends CCSprite, might have the following methods: Player::Player () { this->setPosition } ( ccp(0,0) ); Player * Player::create () { Player * player = new Player(); if (player && player->initWithSpriteFrameName("player.png")) { player->autorelease(); return player; } CC_SAFE_DELETE(player); return NULL; } For instantiation, you call the static create method. It will create a new Player object as an empty husk version

Download sample

Download