Cocos2d-X development of Chinese chess "four" design game scenario, cocos2d-x "four"

Source: Internet
Author: User

Cocos2d-X development of Chinese chess "four" design game scenario, cocos2d-x "four"

After the design starts, you need to design the game interface.

To clarify the design concept, we should first look at a game interface.


Game interface design ideas:

1. Put a table in the window

2. Place a chessboard on the table

3. Add a new board button to the right of the board. specific functions are not implemented for the moment.

4. Add the start button to the right of the board. specific functions are not implemented for the moment.

5. Add the regret button to the right of the board. specific functions are not implemented for the moment.

6. Add the difficulty button to the right of the board. specific functions are not implemented for the moment.

7. Add a sound button to the right of the board. specific functions are not implemented for the moment.

8. Add a return button to the right of the board. specific functions are not implemented for the moment.

9. Add a Voice label to the right of the table

10. Add a Return label to the right of the table

Note:

1. All the functions mentioned above are implemented in SceneGame. h/SceneGame. cpp.

2. The game was improved before I wrote this blog, so no features were added in the previous blog.


To put a table in the window:

// Create a table CCSprite * desk = CCSprite: create ("floor.jpg"); this-> addChild (desk ); // set the table location desk-> setPosition (ccp (winSize. width/2, winSize. height/2); // compress the table desk-> setScaleX (winSize. width/desk-> getContentSize (). width); desk-> setScaleY (winSize. height/desk-> getContentSize (). height );


To put a chessboard on the table:

// Create a checker CCSprite * plate = CCSprite: create ("background.png"); this-> addChild (plate); // set the stroke to (0, 0) plate-> setAnchorPoint (CCPointZero); // set the Board position plate-> setPosition (_ plateOffset); // compress the Board: (the window height-offset y coordinate * 2) /Image Height plate-> setScale (winSize. height-_ plateOffset. y * 2)/plate-> getContentSize (). height );


Add buttons and labels on the table

// Create Menu CCMenu * menu = CCMenu: create (); this-> addChild (menu); // create start button CCMenuItem * itemStart = CCMenuItemImage :: create ("start.jpg", "start.jpg", this, menu_selector (SceneGame: Start); menu-> addChild (itemStart); itemStart-> setPositionX (190 ); itemStart-> setPositionY (120); // create a new registry button CCMenuItem * itemNew = CCMenuItemImage: create ("new.jpg", "new.jpg", this, menu_selector (SceneGame :: new); menu-> addChild (itemNew); itemNew-> setPositionX (itemStart-> getPositionX (); itemNew-> setPositionY (itemStart-> getPositionY () + 60 ); // create regret button CCMenuItem * item = CCMenuItemImage: create ("regret.jpg", "regret.jpg", this, menu_selector (SceneGame: Back )); menu-> addChild (item); item-> setPositionX (itemStart-> getPositionX (); item-> setPositionY (itemStart-> getPositionY ()-60 ); // create Pause button CCMenuItem * itemPause = CCMenuItemImage: create ("pause.jpg", "pause.jpg", this, menu_selector (SceneGame: Pause )); menu-> addChild (itemPause); itemPause-> setPositionX (itemStart-> getPositionX (); itemPause-> setPositionY (itemStart-> getPositionY ()-60-60 ); // create Difficulty button CCMenuItem * itemDifficulty = CCMenuItemImage: create ("difficulty.jpg", "difficulty.jpg", this, menu_selector (SceneGame: Difficulty )); menu-> addChild (itemDifficulty); itemDifficulty-> setPositionX (itemStart-> getPositionX (); itemDifficulty-> setPositionY (itemStart-> getPositionY ()-60-60-60 ); // create a playing background music button CCMenuItem * itemVoice = CCMenuItemImage: create ("openVolice.png", "openVolice.png.png", this, menu_selector (SceneGame: Voice )); menu-> addChild (itemVoice); itemVoice-> setPositionX (itemStart-> getPositionX (); itemVoice-> setPositionY (itemStart-> getPositionY () -60-60-60-60); // create a background music stop button itemCloseVoice = CCMenuItemImage: create ("closeVolice.png", "closeVolice.png", this, menu_selector (SceneGame :: voice); menu-> addChild (itemCloseVoice); itemCloseVoice-> setPositionX (itemStart-> getPositionX (); itemCloseVoice-> setPositionY (itemStart-> getPositionY () -60-60-60-60); itemCloseVoice-> setVisible (false); // CCLog ("x = % lf", itemStart-> getPositionX ()); // CCLog ("y = % lf", itemStart-> getPositionY ()-240); // create a label and display the following text :: create ("Voice", "Arial", 25); addChild (label); // set the text position label-> setPosition (ccp (winSize. width/2 + 120, winSize. height/2-120); // set the text color label-> setColor (ccc3 (0, 0, 0); // create the return button CCMenuItem * itemReturn = CCMenuItemImage:: create ("return.png", "return.png", this, menu_selector (SceneGame: Return); menu-> addChild (itemReturn ); itemReturn-> setPositionX (itemStart-> getPositionX (); itemReturn-> setPositionY (itemStart-> getPositionY ()-60-60-60-60-60 ); itemReturn-> setScale (0.2f); // create a label. The displayed text is "CCLabelTTF * label1 = CCLabelTTF: create (" Return "," Arial ", 25 ); addChild (label1); // set the text position label1-> setPosition (ccp (winSize. width/2 + 120, winSize. height/2-180); // set the text color label1-> setColor (ccc3 (0, 0, 0 ));



Zookeeper

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.