Use cocos2d-x to remove CandyCrushSaga

Source: Internet
Author: User
0

It should be noted that GameTile is placed in each square of the GameBox. The player switches GameTile, in fact, to the sprite inside the GameTile. The GameTile itself does not move the position.

Class GameTile: public Node {public: int x; int y; int value; // 1-6 6 types of block int comboValue; // 1: horizontal elimination item, 2: vertical elimination Sprite * sprite; // The sprite, public: GameTile (int ax, int ay) displayed in the box );~ GameTile (); bool nearTile (GameTile * other tile); // whether to connect void trade (GameTile * other tile); // switch gameTile, in fact, it is the sprite void changeComboTile (int orient) of the Exchange; // It is converted to the combo Point pixPosition (); // The pixel coordinates corresponding to x and y are returned, used to exchange sprite void refreshDebugInfo ();};

Iii. GameBox
1. First, generate all the gametitles. The newly generated GameTile does not have sprite.
2. After GameScene onEnterTransitionDidFinish, The GameBox check method is called and all gametitles are empty. Therefore, the sprite filling process is started.
3. After GameScene is switched to gameTile, GameBox check is triggered. GameBox check is used to check whether there are any objects that can be eliminated. If not, GameScene is notified to restore the gameTile of the switch, and the gameTile is eliminated, then, GameBox eliminates the corresponding sprite, fills in the new sprite, and executes check.

4. Provide the source code:
The Code is based on the cocos2d-x-3.0alpha0 version, download it and run it in the projects directory.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.