The first one is in the header file
Part of the code is learning the same as most write yourself.
class Helloworld:public cocos2d::cclayer{public:virtual BOOL Init (); Static cocos2d::ccscene* scene (); void Menuclosecallback (ccobject* psender); Create_func (HelloWorld); The above for their own initiative generated code bool Doup (); Implement up and down move function bool Dodown (); BOOL Doleft (); BOOL Doright (); void Createcardsprite (cocos2d::ccsize size); Create a 4*4 elf matrix void HelloWorld:: Random_createcardsprite (); Randomly generated digital random position generated bool HelloWorld:: Fullscreen (); Infer if full screen is full of numbers and cannot move bool HelloWorld:: Gameover ();//Game over void random_num (int x,int y);//randomly generate 2 and 4 void Rando M_createcardsprite_easy (int flag); The purpose of setting this function is to set the difficulty of the game because it does not implement the ability to choose the difficulty, so this function only has to call Random_createcardsprite (int flag); function void HelloWorld:: Random_crea Tecardsprite (int flag); Random generation of the regular generation of numbers to move upward is generated in the following Private:int Firstx,firsty,endx,endy; Touch point coordinates cardsprite *CARDNUM[4][4]; Create an array object with digital energy 4*4};
Class Cardsprite:public Cocos2d::ccsprite{public: virtual bool init (); static cardsprite* createcardsprite (int numbers,int width,int height,float cardspritex,float CardSpriteY); Create_func (cardsprite); int GetNumber ();//Get the number represented by this Genie void Setnumber (int newnumbers);//change the number represented by this Genie void Change_num_view (); Change the appearance of a number by the number size to convert the color private:int numbers; The figure represented by this genie is void numberinit (int numbers,int width,int height,float x,float Y); Initializes the "number" //definition control that displays the number Cocos2d::cclabelttf *labelttfcardnumber; Show background cocos2d::cclayercolor *LAYERCOLORBG;};
copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.
Beginner COCOS2DX write 2048 to share with everyone