Downgrading and testing the client and some code annotations of the dark world on MAC (based on Firefly)

Source: Internet
Author: User

Address: http://www.myexception.cn/program/1399860.html

Downgrading and testing the client and some code annotations of the dark world on MAC (based on Firefly)

Downgrading and testing the client and some code annotations in the dark world on MAC (based on Firefly)

Currently there are two clients, one based on cocos2d-x, one based on unity3d, the two clients debug run the official website also has related tutorials, I am based on my own MAC environment debugging run.

First, the client based on coco2d-x

1. The fastest way is to first install xcode on Mac, I use xcode4.6, then download the cocos2d-x installation package, I use 2.1.5, directly decompress it to documents to get the cocos2d-x-2.1.5, don't worry about installing his template, then download the dark world coco2d-x client, my version is 1.4, actually more than 200 m, unzip, get a folder named tsdemo, create a folder named project in the cocos2d-x-2.1.5 (in fact the name is casual), drag tsdemo to this folder;

2. Go to the tsdemo directory, select proj. iOS, and click Enter. Under this directory, double-click tsdemo. xcodeproj to import the project to xcode;

3. An error may occur when you click run directly because no path is added. Click tsdemo of the project, select the project under targets on the right, and find the header search paths in build settings, click the plus sign in the lower left corner and enter "$ (project_name)/classes/JSON/include/JSON" to add the path to the project.

4. Now the client is running.

Reference: http://www.9miao.com/thread-33127-1-1.html

Ii. U3D Client

1. Install unity3d 4.xand register the free version;

2. Download the dark world U3D client, which is currently version 1.0. decompress the package diabloworldv1.unitypackage;

3. Open unity3d to create a project. Right-click assets and choose import package. The default package is diabloworldv1.unitypackage;

4. After the import, select map in assets, double-click the start scenario, and click run on the toolbar.

5. If you want to modify the Server IP address and port, in the start scenario, select netmar under globals in hehierarchy on the left, and sip and iport under inspector on the right represent the host address and port respectively.

Reference: http://www.9miao.com/thread-42791-1-1.html

 

Finally, we will attach some Chinese introductions to the client's single-ended code.

About cocos2d-x:

-----------------------------------------------------

Some classes:
1. The logo started by the loginregister \ logo. H program, which has a category, which will automatically switch after 2 seconds
2. loginregister \ layerlogin. h logon Interface
3. Some operations of the CDATA. H system, playing audio
4. extentionclass \ Network \ socketmanager. h client socket management class, which is a singleton. The startsocket method contains the server address and port
5. extentionclass \ Network \ socketclient. h socketclient has two threads to send and receive messages.
6. Loading. h wait for uialert
7. On the headfile \ zhujiemian \ homepage. h homepage, send a message [4500] to the server during init and start the timer to wait for the server to reply.
After receiving the reply, initialize the form inittitle, btnsloading, zhuangtaiload
8. headfile \ zhujiemian \ levelmap. h clkbuilding click a copy to respond to the event
9. In the headfile \ zhujiemian \ popwindow. h pop-up window, click the copy and call the displayed form. buildingpop: Fight to send the combat request.
10. Firework. h combat Scene Presentation class

-----------------------------------------------------

Login process:

1. logon interface: loginregister \ layerlogin. h

2. Singleton instantiation: layerlogin: init
Socketmanager: getinstance ()-> startsocket ();

3. Click login: layerlogin: menuitemcallbacklogin

3.1 Use socketmanager to send the username and password for the singleton

JSON: fastwriter writer;

JSON: Value person;

Person ["username"] = username;

Person ["password"] = password;

STD: String json_file = writer. Write (person );
// 192.168.1.210 114.252.70.61 183.60.243.195

Cclog ("% s", json_file.c_str ());

Socketmanager: getinstance ()-> sendmessage (json_file.c_str (), 101 );

3.2 Timer: checks every 0.2 seconds whether the returned data is received. If yes, the timer is canceled.
This-> schedule (schedule_selector (layerlogin: cancelogindata), 0.2 );

4. logon management class: extentionclass \ Network \ socketmanager. h

4.1 server address configuration: socketmanager: startsocket
_ Socket = new socketclient ("192.168.1.210", 11009,1, 1, null );

4.2 send a message: socketmanager: sendmessage
Message * MSG = _ socket-> constructmessage (data, commandid );

_ Socket-> sendmessage _ (MSG, false );

5. socketclient class: extentionclass \ Network \ socketclient. h

5.1 message constructor: socketclient: constructmessage

5.2 message sending function: socketclient: sendmessage _

// Lock
Mylock lock (& m_sendqueue_mutex );

// Queue messages
M_sendmessagequeue.push (MSG );

6. Message class: extentionclass \ Network \ message. h

-----------------------------------------------------

About U3D:

A little bit, the login page script, in assets \ scripts \ views, is named dengluview. CS, others haven't been carefully looked at yet. It seems that all the data is encapsulated into an entity class, in globals. CS

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.