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.