Cocos2d x Game Development Essentials Sample Chapter

download Cocos2d x Game Development Essentials Sample Chapter

of 18

Transcript of Cocos2d x Game Development Essentials Sample Chapter

  • 8/17/2019 Cocos2d x Game Development Essentials Sample Chapter

    1/18

     

    Cocos2d-x Game DevelopmentEssentials

    Frahaan Hussain

    Arutosh Gurung

    Gareth Jones

    Chapter No. 5

    "The Game Sprites"

  • 8/17/2019 Cocos2d x Game Development Essentials Sample Chapter

    2/18

    In this package, you will find:The author ’s biography

    A preview chapter from the book, Chapter no.5 "The Game Sprites"

    A synopsis of the book’s content 

    Information on where to buy this book

     About the AuthorsFrahaan Hussain is a young programmer who contributes towards the community inmany ways, this book being the latest. He runs his own company (Sonar Systems). Hehas a degree in Computer Games Programming, making him fully aware of the ins

    and outs of game development. Frahaan has worked for Accenture, which is the world's biggest consultancy firm, and he also runs a small personal company on the side

    (ThunderKeyBolt).

    I would like to thank Arutosh Gurung for the artwork that went into this book, GarethJones for code assistance, and my father, Siddique Hussain, for his help in planning

    the book.

    http://www.packtpub.com/game-development/cocos2d-x-game-development-essentials

  • 8/17/2019 Cocos2d x Game Development Essentials Sample Chapter

    3/18

     

    Company details:

      Company name: Sonar Systems

      Company logo:

      Official website:

      Facebook:

      Twitter:  Google+:

      YouTube:

    Arutosh Gurung is the cofounder of Sonar Systems. He is the main proofreader inthe company and is an amazing artist with business acumen that backs up his

    creative abilities.

    Gareth Jones is an amazing developer who works with Sonar Systems. He is the pointof contact within the team for tips on coding.

    http://www.packtpub.com/game-development/cocos2d-x-game-development-essentials

  • 8/17/2019 Cocos2d x Game Development Essentials Sample Chapter

    4/18

    Cocos2d-x Game

    Development EssentialsCocos2d-x Game Development Essentials is your quick and easy guide to learningsnippets of Cocos2d-x functionality for game development or how to make a gamefrom scratch. This book uses the concept of creating a game to teach you the essentials

    of game development with Cocos2d-x while covering generic game design practices.This book will teach you the essentials using C++, making it ideal for the millions of

    existing developers out there looking to learn Cocos2d-x for a job or to start their ownsoftware house, to develop quality mobile games. Unfortunately, the number ofCocos2d-x books is extremely low with a scarcity of online resources.

    However, this book aims to help in the solution of providing great quality learning

    materials that are easy to understand and follow for beginners or experts who arelooking for a refresh.

    We have launched the application that we have made during the course of this book.You can refer to the following links for this application:

    •  YouTube:•  App Store:

    •  Google Play:

    What This Book CoversChapter 1, Setting Up, shows you how to set up a new project using Cocos2d-x and

     preparation for the game.

    Chapter 2, Adding Scenes, covers how to add additional scenes to create the corefoundations of a game.

    Chapter 3, Adding Game Menus, introduces the process of creating a game menu usingmenu items.

    Chapter 4, Scene Transitions, covers how to implement screen transitions to move fromone scene to the next.

    Chapter 5, The Game Sprites, covers how to implement sprites to set the foundations of a playable game.

    Chapter 6 , Implementing Actions, covers how to make your sprites move and act with a

    sense of motion within the game.

    http://www.packtpub.com/game-development/cocos2d-x-game-development-essentials

  • 8/17/2019 Cocos2d x Game Development Essentials Sample Chapter

    5/18

     

    Chapter 7 , Moving the Space Pod Using Touch, covers how to interact with the spaceshipsprite using touch.

    Chapter 8, Collision Detection, shows how to implement collision detection between the player and obstacles to add the final piece of gameplay.

    Chapter 9, Adding Audio to the Game, introduces the concept of sound fi les and how toimplement them into the game using Cocos2d-x.

    Chapter 10, Implementing Accelerometer Support , shows how accelerometer support can

     be incorporated within a game.

    Chapter 11, Problem Solving and What's Next , discusses the unfortunate situations that

    are most likely to be faced while developing a game and how to overcome these issues.

    http://www.packtpub.com/game-development/cocos2d-x-game-development-essentials

  • 8/17/2019 Cocos2d x Game Development Essentials Sample Chapter

    6/18

    !"# %&'# ()*+,#-!"#$ &"'()*+ ,#-- ./#0* 12/ )"+2/." )"* (+2&*$$ 23 /$#4. $(+#)*$ )2 0#$(-'1.'5* 267*&)$ $/&" '$ )"* 6'&8.+2/409 (-'1*+ &"'+'&)*+$9 '40 !"#$%&'(')&*

    ,-'.'/0*.1 :!2,1;<

    =(+#)*$ '+* &25(/)*+ .+'("#&$ )"') '+* /$*0 )2 +*(+*$*4) 267*&)$ )2 6* 0#$(-'1*0,#)"#4 ' $&*4*> 32+ *?'5(-*9 ' (-'1*+ ,2/-0 6* ' $(+#)* ,#)"#4 )"* .'5* *4@#+245*4)<!"*$* (-'1*+ $(+#)*$ ,2/-0 #4)*+'&) ,#)" 2)"*+ $(+#)*$ )"') '+* (+*$*4)<

    !"* )2(#&$ )"') '+* &2@*+*0 #4 )"#$ &"'()*+ '+* '$ 32--2,$A

    B C00#4. $(+#)*$

    B D2$#)#24#4. $(+#)*$

    B E2@#4. $(+#)*$

    =(+#)*$ $#5(-#31 )"* (+2&*$$ 23 0#$(-'1#4. .'5* 267*&)$F12/ 024G) 4**0 )2 &+*')*

    ' 6#)5'( ,#)" '$$#.4*0 5*52+19 (2$#)#24 )"* 6#)5'(9 '40 0+', #)< =(+#)*$ '--2,'-- 23 )"#$ )2 6* 024* 6*"#40 )"* $&*4*$< H2&2$I0J? "'$ 6/#-)J#4 5*)"20$ )2 &+*')*95'4#(/-')*9 '40 0#$(-'1 $(+#)*$<

    K'&" $*&)#24 ,#-- &2@*+ "2, )2 '00 )"* .'5* $(+#)*$ ,#)"#4 )"*#+ '((+2(+#')* $&*4*$'40 5'4#(/-')* )"*5 #3 4*&*$$'+19 32+ *?'5(-*9 52@#4. )"* 6'&8.+2/40 $(+#)* )2(+2@#0* ' $&+2--#4. *33*&)< !"* 32--2,#4. #$ '4 *?'5(-* 23 )"* $(+#)* 0*&-'+')#24 )2'00 ' $(+#)* )2 ' $&*4*A

    auto backgroundSprite = Sprite::create("MainMenuScreen/Background.png");

    http://www.packtpub.com/game-development/cocos2d-x-game-development-essentials

  • 8/17/2019 Cocos2d x Game Development Essentials Sample Chapter

    7/18

    !"# %&'# ()*+,#-

    ! #$ %

    !"* (+*&*0#4. -#4* 23 &20* &+*')*$ ' $(+#)* @'+#'6-* &'--*0 backgroundSprite9,"#&" #$ &+*')*0 3+25 ' DLM #5'.*< N) #$ +*&255*40*0 )"') 12/ /$* DLM #5'.*$

    '$ )"*1 '--2, )+'4$('+*4&1< !"* 6'$#& (+2&*$$ 23 0#$(-'1#4. ' $(+#)* #$ '$ 32--2,$AO< P*&-'+* ' $(+#)*<

    P*&-'+* )"* $(+#)* #4 )"* "*'0*+ #3 #) 4**0$ )2 6* 5'4#(/-')*0'3)*+ )"* 0*&-'+')#24<

    I< N4#)#'-#Q* )"* $(+#)*<

    R< D2$#)#24 )"* $(+#)*<

    S< =*) '41 2)"*+ (+2(*+)#*$9 $/&" '$ )"* $&'-* '40 +2)')#24<

    T< P+', ' $(+#)* )"') #$ "'40-*0 @#' H2&2$I0J?<

    &''()* +,- ./() .-)0 123(+-1!"* 24-1 $(+#)* )"') 4**0$ )2 6* 0#$(-'1*0 #4 )"* E'#4 E*4/ $&*4* #$ )"*6'&8.+2/40< C00 )"* 32--2,#4. &20* 6*-2, )"* 5*4/ &20* #4 )"* init() 5*)"20 ,#)"#4 )"* MainMenuScene.cpp !-*A

    auto backgroundSprite = Sprite::create("MainMenuScreen/Background.png");

    backgroundSprite->setPosition(Point((visibleSize.width / 2) +origin.x, (visibleSize.height / 2) + origin.y));

    this->addChild(backgroundSprite, -1);

    !"* !+$) $)')*5*4) 23 )"* (+*&*0#4. &20* 0*&-'+*$ '40 #4#)#'-#Q*$ ' $(+#)* &'--*0backgroundSprite ,#)" ' DLM #5'.*<

    !"* $*&240 $)')*5*4) $*)$ )"* (2$#)#24 23 )"* 6'&8.+2/40 $(+#)* ') )"* &*4)*+ 23)"* $&+**4 /$#4. )"* @#$#6-* $#Q*9 ,"#&" #$ )"* '+*' 23 )"* $&+**4 )"') #$ '@'#-'6-* 24' ('+)#&/-'+ 0*@#&*9 '$ )"*+* '+* 0#33*+*4) $&+**4 $#Q*$< !"* 2+#.#4 #$ /$*0 '$ $25*0*@#&*$ :5'#4-1 C40+2#0; 024G) $)'+) ') :U9 U; 6*&'/$* 23 24$&+**4 6/))24$ '40 $2 24<!"#$ ,#-- "*-( )2 2@*+&25* (2$#)#24#4. #$$/*$

  • 8/17/2019 Cocos2d x Game Development Essentials Sample Chapter

    8/18

    ."&),#* /

    ! #4 %

    !"* )"#+0 $)')*5*4) '00$ )"* $(+#)* '$ ' &"#-0 )2 )"* $&*4* '40 '-$2 $*)$ )"* QJ#40*?@'-/*9 ,"#&" $)')*$ )"* 2+0*+ 23 )"* #)*5$< C$ )"* 6'&8.+2/40 $(+#)* $"2/-0 6* 6*-2,

    '-- )"* 2)"*+ #)*5$9 )"* QJ#40*? #$ $*) )2-1

     $#4&* 61 0*3'/-) )"* 2)"*+ 267*&)$ '+* $*))2 0< C-)"2/." )"* QJ#40*? ,'$ $*) )2 -19 ' -#))-* )"#4. )2 42)* #$ )"') '41 420* '00*0'3)*+ #) ,#-- '/)25')#&'--1 6* 24 )2( 23 )"* (+*@#2/$ 420*$ #3 )"* QJ#40*? #$4G) $*)<

    !"* init() 5*)"20 $"2/-0 .#@* 12/ )"* 32--2,#4. $&+**4$"2)A

    !"* MVN '3)*+ '00#4. )"* E'#4 E*4/ $(+#)*$ ,#-- -228 '$ $"2,4 #4 )"*32--2,#4. $&+**4$"2)A

    http://www.packtpub.com/game-development/cocos2d-x-game-development-essentials

  • 8/17/2019 Cocos2d x Game Development Essentials Sample Chapter

    9/18

    !"# %&'# ()*+,#-

    ! #5 %

    &''()* +,- 6/7- 89-3 123(+-1!"* 24-1 $(+#)* )"') 4**0$ )2 6* 0#$(-'1*0 #4 )"* M'5* W@*+ $&*4* #$ )"* 6'&8.+2/40<C00 )"* 32--2,#4. &20* 6*-2, )"* 5*4/ &20* #4 )"* init() 5*)"20 ,#)"#4 )"*GameOverScene.cpp !-*9 '$ ,* 0#0 #4 )"* (+*@#2/$ $*&)#24A

    auto backgroundSprite = Sprite::create("GameOverScreen/Game_Over_Screen_Background.png");

    backgroundSprite->setPosition(Point((visibleSize.width / 2) +origin.x, (visibleSize.height / 2) + origin.y));

    this->addChild(backgroundSprite, -1);

    !"* MVN '3)*+ '00#4. )"* M'5* W@*+ $(+#)*$ $"2/-0 -228 -#8* ,"') #$ $"2,4 #4 )"*

    32--2,#4. $&+**4$"2)A

    &''()* +,- :/01- 123(+-1!"* 24-1 $(+#)* )"') 4**0$ )2 6* 0#$(-'1*0 #4 )"* D'/$* $&*4* #$ )"* 6'&8.+2/40<C00 )"* 32--2,#4. &20* 6*-2, )"* 5*4/ &20* #4 )"* init() 5*)"20 ,#)"#4 )"*PauseScene.cpp !-*9 '$ ,* 0#0 #4 )"* (+*@#2/$ $*&)#24A

    auto backgroundSprite = Sprite::create("PauseScreen/Pause_Background.png");

    http://www.packtpub.com/game-development/cocos2d-x-game-development-essentials

  • 8/17/2019 Cocos2d x Game Development Essentials Sample Chapter

    10/18

    ."&),#* /

    ! #; %

    backgroundSprite->setPosition(Point((visibleSize.width / 2) +origin.x, (visibleSize.height / 2) + origin.y));

    this->addChild(backgroundSprite, -1);

    !"* MVN '3)*+ '00#4. )"* D'/$* $(+#)*$ $"2/-0 -228 -#8* ,"') #$ $"2,4 #4 )"*32--2,#4. $&+**4$"2)A

    &''()* +,- 6/7- 123(+-1V4-#8* #4 )"* (+*@#2/$ 6'&8.+2/40$9 )"* M'5* $&*4*G$ 6'&8.+2/40 ,#-- 6* 52@#4.9(+2@#0#4. ' $&+2--#4. *33*&)< X*32+* 12/ 0#@* #4)2 )"* 6'&8.+2/40 &20*9 '4 update 3/4&)#24 4**0$ )2 6* $&"*0/-*0 )2 6* &'--*0 #4 *@*+1 3+'5* /$#4. )"* 32--2,#4. $)*($A

    O< =&"*0/-* )"* update 3/4&)#24 #4 )"* init() 5*)"20 /$#4. )"*32--2,#4. &20*A

    this->scheduleUpdate();

    I< P*&-'+* )"* update 3/4&)#24 #4 )"* GameScene.h !-* /$#4. )"*

    32--2,#4. &20*Avoid update(float dt);

    http://www.packtpub.com/game-development/cocos2d-x-game-development-essentials

  • 8/17/2019 Cocos2d x Game Development Essentials Sample Chapter

    11/18

    !"# %&'# ()*+,#-

    ! $< %

    R< N5(-*5*4) )"* update 3/4&)#24 #4 )"* GameScene.cpp !-* /$#4. )"*32--2,#4. &20*A

    void GameScreen::update(float dt){

    }

    !"* update 3/4&)#24 #$ /$*0 )2 "'40-* )"* .'5*G$ -2.#& '40 )'8*$ ' float ('+'5*)*+&'--*0 0*-)' )#5*9 ,"#&" #$ )"* )#5* 6*),**4 3+'5*$< C$ '-- 0*@#&*$ '+* 42) &'('6-* 23+/44#4. ') YU 3($9 )"#$ #$ 3'&)2+*0 #4 0/+#4. .'5*(-'1 )2 (+2@#0* ' $522)" *?(*+#*4&*'&+2$$ ' ,#0* @'+#*)1 23 0*@#&*$<

    !"* 32--2,#4. '+* )"* $)*($ )2 #5(-*5*4) ' $&+2--#4. 6'&8.+2/40A

    O< P*&-'+* ' $(+#)* '++'1 32+ )"* 6'&8.+2/40 &24$#$)#4. 23 ),2 #)*5$< C$ )"*

    6'&8.+2/40 ,#-- 6* $&+2--#4.9 ),2 $(+#)*$ ,#-- 6* /$*0 )2 (+2@#0* )"* #--/$#2423 ' &24$#$)*4) 6'&8.+2/40< Z2,*@*+9 24&* ' $(+#)* "'$ .24* 233 )"* $&+**49#) ,#-- +*$*) 6'&8< !"* 32--2,#4. &20* 4**0$ )2 6* '00*0 ,#)"#4 )"* "*'0*+A

    cocos2d::Sprite *backgroundSpriteArray[2];

    I< N4#)#'-#Q* )"* $(+#)* '++'1 '40 $*) )"* (2$#)#24 23 )"* $(+#)*$> $29 24* #$0#$(-'1*0 24 )"* $&+**4 #4#)#'--19 '40 )"* 2)"*+ 24* 6*-2, )"* $&+**4 ,#-- 6*0#$(-'1*0 '$ )"* 6'&8.+2/40 $&+2--$ /(,'+0$< !"*49 '00 )"*$* )2 )"* $&*4*'$ &"#-0+*4> '-- )"#$ ,#-- 6* 024* ,#)"#4 )"* init() 5*)"20A

    for (int i = 0; i < 2; i ++)

    {

      backgroundSpriteArray[i] = Sprite::create  ("GameScreen/Game_Screen_Background.png");

      backgroundSpriteArray[i]->setPosition  (Point((visibleSize.width / 2) + origin.x, (-1 *

    visibleSize.height * i) + (visibleSize.height / 2) +origin.y));

      this->addChild(backgroundSpriteArray[i], -2);

    }

    R< L*?)9 52@* )"* $(+#)*$ ,#)"#4 )"* update() 5*)"20 61 3'&)2+#4. #4 )"*0*-)' )#5* :U

  • 8/17/2019 Cocos2d x Game Development Essentials Sample Chapter

    12/18

    ."&),#* /

    ! $= %

      (Point(backgroundSpriteArray[i]->getPosition().x,backgroundSpriteArray[i]->getPosition().y + (0.75 *visibleSize.height * dt)));

      }

    S< C-)"2/." )"* 6'&8.+2/40$ $&+2--9 )"*1 02 42) +*$*) 24&* )"*1 "'@* .24*'62@* )"* $&+**4< C00 )"* 32--2,#4. &20* '62@* )"* (+*@#2/$ &20*A

    Size visibleSize = Director::getInstance()->getVisibleSize();

    Point origin = Director::getInstance()->getVisibleOrigin();

    for (int i = 0; i < 2; i ++)

    {

      if (backgroundSpriteArray[i]->getPosition().y >=visibleSize.height + (visibleSize.height / 2) -1)

      {

      backgroundSpriteArray[i]->setPosition

      (Point((visibleSize.width / 2) + origin.x, (-1 *visibleSize.height) + (visibleSize.height / 2)));

      }

    }

    !"* 6'&8.+2/40 #$ 42, $&+2--#4. '40 +*$*)$ 24&* #) "'$ .24* 233 )"* $&+**4<

    L2,9 )"* $&+2--#4. '$)*+2#0$ ,#-- 6* #5(-*5*4)*0< !"* '$)*+2#0$ ,#-- $(',4 *@*+1 I

  • 8/17/2019 Cocos2d x Game Development Essentials Sample Chapter

    13/18

    !"# %&'# ()*+,#-

    ! $> %

      Point origin = Director::getInstance()->  getVisibleOrigin();

      int asteroidIndex = (arc4random() % 3) + 1;  __String* asteroidString = __String::  createWithFormat("GameScreen/Asteroid_%i.png",

    asteroidIndex);

      Sprite *tempAsteroid = Sprite::create(asteroidString->  getCString());

      int xRandomPosition = (arc4random() % (int)  (visibleSize.width - (tempAsteroid->  getContentSize().width / 2))) + (tempAsteroid->  getContentSize().width / 2);

      tempAsteroid->setPosition(Point(xRandomPosition +origin.x, -tempAsteroid->getContentSize().height +origin.y));

      asteroids.push_back(tempAsteroid);

      this->addChild(asteroids[asteroids.size() - 1], -1);

    }

    T< X*32+* #5(-*5*4)#4. )"* &20* )2 &"*&8 ,"*)"*+ '4 '$)*+2#0 "'$ .24* 233 )"*$&+**49 -*)G$ .2 2@*+ ,"') )"* spawnAsteroid(float dt) 5*)"20 02*$A

        ^#+$)-19 )"* @#$#6-* $#Q* '40 2+#.#4 '+* 0*&-'+*0 '40 #4#)#'-#Q*0

        !"*49 asteroidIndex $)2+*$ ' +'4025 4/56*+ )"') 0*)*+5#4*$,"#&" '$)*+2#0 ,#-- 6* $(',4*0 :'$ )"*+* '+* )"+** 0#33*+*4) '$)*+2#0$;

        L*?)9 )"* 3#-*4'5* 32+ )"* +'4025 '$)*+2#0 #$ &+*')*0 /$#4. H2&2$I0J?G$ 6/#-)J#4 __String 267*&)9 '40 /$#4. this9 ' )*5(2+'+1 '$)*+2#0$(+#)* #$ 0*&-'+*0 '40 #4#)#'-#Q*0

        !"* '$)*+2#0 #$ )"*4 (2$#)#24*0 6*-2, )"* $&+**4 '40 +'4025-1 '-24.)"* 0 '?#$

        !"*49 )"* '$)*+2#0 #$ '00*0 )2 )"* '$)*+2#0$G @*&)2+

        !"* '$)*+2#0 #$ '00*0 '$ ' &"#-0 )2 )"* $&*4*

    http://www.packtpub.com/game-development/cocos2d-x-game-development-essentials

  • 8/17/2019 Cocos2d x Game Development Essentials Sample Chapter

    14/18

    ."&),#* /

    ! $? %

    Y< ^#4'--19 '00 )"* 32--2,#4. &20* )2 )"* update(float dt) 5*)"209 ,"#&",#-- 52@* )"* '$)*+2#0$ ') )"* $'5* $(**0 '$ )"* $(**0 ') ,"#&" )"*

    6'&8.+2/40 #$ 52@#4.< !"*49 #) ,#-- &"*&8 ,"*)"*+ )"* '$)*+2#0 "'$ 52@*0233 )"* $&+**4> #3 $29 #) ,#-- +*52@* )"* '$)*+2#0 3+25 )"* $&*4* '40 3+25 )"*'$)*+2#0G$ @*&)2+A

    for (int i = 0; i < asteroids.size(); i++)

    {

      asteroids[i]->setPosition(Point(asteroids[i]->  getPosition().x, asteroids[i]->getPosition().y +

    (0.75 * visibleSize.height * dt)));

      if (asteroids[i]->getPosition().y >visibleSize.height * 2)

      {

      this->removeChild(asteroids[i]);

      asteroids.erase(asteroids.begin() + i);

      }

    }

    !"* !4'- $(+#)* )2 6* '00*0 #$ )"* (-'1*+G$ $('&*$"#(> /$* )"* 32--2,#4. $)*($A

    O< P*&-'+* )"* (-'1*+ $(+#)* #4 )"* GameScene.h !-*A

    cocos2d::Sprite *playerSprite;

    I< N4#)#'-#Q* )"* (-'1*+ $(+#)* ,#)"#4 )"* init() 5*)"20 #4 )"*GameScene.cpp !-*A

    playerSprite = Sprite::create("GameScreen/Space_Pod.png");

    R< D2$#)#24 )"* (-'1*+ $(+#)* 6*-2, )"* ('/$* 6/))24 &*4)*+*0 '-24. )"* 0 '?#$A

    playerSprite->setPosition(Point(visibleSize.width / 2,pauseItem->getPosition().y - (pauseItem->getContentSize().height / 2) - (playerSprite->getContentSize().height / 2)));

    S< L2, '00 )"* (-'1*+ $(+#)* '$ ' &"#-0 )2 )"* $&*4*A

    this->addChild(playerSprite, -1);

    L2, )"') )"* $(+#)*$ "'@* 6**4 #5(-*5*4)*09 "*+* '+* )"* #5'.*$ 23 "2, )"*GameScene.h '40 GameScene.cpp !-*$ $"2/-0 -228

  • 8/17/2019 Cocos2d x Game Development Essentials Sample Chapter

    15/18

    !"# %&'# ()*+,#-

    ! $@ %

    !"* 32--2,#4. $&+**4$"2) $"2,$ "2, )"* GameScene.h !-* $"2/-0 -228 '3)*+ '-- )"*&20* "'$ 6**4 '00*0 61 32--2,#4. )"* (+*@#2/$ $)*($A

    !"* 32--2,#4. $&+**4$"2) $"2,$ "2, )"* init() 5*)"20 #4$#0* GameScene.cpp $"2/-0 -228 '3)*+ '-- )"* &20* "'$ 6**4 '00*0 61 32--2,#4. )"* (+*@#2/$ $)*($ )2#4#)#'-#Q* )"* .'5*G$ $(+#)*$A

    http://www.packtpub.com/game-development/cocos2d-x-game-development-essentials

  • 8/17/2019 Cocos2d x Game Development Essentials Sample Chapter

    16/18

    ."&),#* /

    ! $# %

    !"* 32--2,#4. $&+**4$"2) $"2,$ "2, )"* update() '40 spawnAsteroid() 5*)"20$#4$#0* GameScene.cpp $"2/-0 -228 '3)*+ '-- )"* &20* "'$ 6**4 '00*0 61 32--2,#4.

    )"* (+*@#2/$ $)*($ #4 2+0*+ )2 '00 )"* '$)*+2#0$ +'4025-1 )2 (+2@#0* ' .'5*(-'1*-*5*4) )2 )"* .'5*A

    N4 )"#$ )/)2+#'-9 '-)"2/." $(**0 ,'$ #5(-*5*4)*0 '$ ' 5'.#& 4/56*+32+ .*4*+'- 0*@*-2(5*4) (/+(2$*$9 )"#$ $"2/-0 6* '@2#0*0 '40#defines 2+ @'+#'6-*$ $"2/-0 6* /$*0

  • 8/17/2019 Cocos2d x Game Development Essentials Sample Chapter

    17/18

    !"# %&'# ()*+,#-

    ! $$ %

    ^#4'--19 )"#$ #$ "2, 2/+ MVN ,#-- -228A

    A077/3B!"#$ &"'()*+ &2@*+*0 $(+#)*$9 ,"#&" '--2, .'5* 267*&)$ )2 6* '00*0 '40 0+',4,#)"#4 ' $&*4*< !"* $(+#)*$ '00*0 #4 )"#$ &"'()*+ ,#-- $*+@* '$ )"* 6'$#$ 32+ )"*.'5*(-'1 )"') ,#-- 6* #5(-*5*4)*0 2@*+ )"* 4*?) 3*, &"'()*+$< !"* 4*?) &"'()*+,#-- &2@*+ $(+#)* '&)#24$ )"') '--2, $(+#)*$ )2 6* 5'4#(/-')*09 32+ *?'5(-*9 +2)')#24'40 $&'-#4.9 '-- 23 ,"#&" '+* (+2@#0*0 @#' H2&2$I0J?

  • 8/17/2019 Cocos2d x Game Development Essentials Sample Chapter

    18/18

    Where to buy this bookYou can buy Cocos2d-x Game Development Essentials from the Packt Publishing

    website:

    .

    Free shipping to the US, UK, Europe and selected Asian countries. For more information, please

    read our  shipping policy. 

    Alternatively, you can buy the book from Amazon, BN.com, Computer Manuals and

    most internet book retailers.

    www.PacktPub.com 

    http://www.packtpub.com/Shippingpolicyhttp://www.packtpub.com/Shippingpolicyhttp://www.packtpub.com/Shippingpolicyhttp://www.packtpub.com/http://www.packtpub.com/http://www.packtpub.com/game-development/cocos2d-x-game-development-essentialshttp://www.packtpub.com/http://www.packtpub.com/Shippingpolicy