To the Cocos Siege of the Lion March HelloWorld

Source: Internet
Author: User

1: When we find a project to open the compilation does not pass, it may be because of different versions of the reasons, then we how to view the Cocos2d-x source version
LIBCOCOS2D below in the engineering catalogue \cocos2dx\cocos2d.cpp

#include "cocos2d.h"NS_CC_BEGINconstchar* cocos2dVersion(){    return"cocos2d-x 2.2.6";}NS_CC_END2:工程的入口:main.cpp下面

int Apientry _tWinMain (hinstance hinstance,
HInstance hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
Unreferenced_parameter (hprevinstance);
Unreferenced_parameter (lpCmdLine);

// create the application instanceAppDelegate app;CCEGLView* eglView = CCEGLView::sharedOpenGLView();eglView->setViewName("myHello");eglView->setFrameSize(480, 320);return CCApplication::sharedApplication()->run();

}

The real entrance to the project is in:

BOOL Appdelegate:: applicationdidfinishlaunching() {//Initialize directorCcdirector*Pdirector=Ccdirector:: Shareddirector(); Cceglview*Peglview=Cceglview:: Sharedopenglview();pD Irector -Setopenglview (Peglview);//Turn on display FPSPdirector -Setdisplaystats (true);//Set FPS. The default value is 1.0/60 if you don ' t call thisPdirector -Setanimationinterval (1.0 /  -);//Create a scene. It ' s an Autorelease objectCcscene*Pscene=HelloWorld:: Scene();//RunPdirector -Runwithscene (Pscene);return true;}

A few important carding points:
Appdelegate Private Inheritance Ccapplication
Ccapplication Public Inheritance Ccapplicationprotocol
Ccapplicationprotocol defines the interface
Ccapplication different logic for each platform
Appdelegate only realizes the interface in the Ccapplicationprotocol, and realizes the localization of the agent function.
Here in fact, the use of proxy mode, agent mode of improvement;

Appdelegate app;
Ccapplication::sharedapplication ()->run ()

The App object is assigned to the Ccapplication::sharedapplication ()
Ccapplication * sm_psharedapplication;
Here: Subclass object assigned to parent class
The parent class calls the run function again. The run function calls the applicationdidfinishlaunching () function, which is implemented by Appdelegate, and the entire process uses a polymorphic mechanism.

3: Game Logic structure:

A director can only run one scene at a time, and in one scene, it is possible to load multiple layers simultaneously.
A layer can be loaded with multiple sprites. Layers can also be added to the layer.

4: Anchor point:
Anchor points affect scaling. Affect rotation.
The anchor point is like a nail, you have to nail a piece of paper to the wall, the nail you can put in the middle of the paper, you can also put in the upper left corner of the paper and so on the lower right corner. In short, the anchor point is not the center of gravity.

Just like a piece of paper, if your nails in the lower left corner, then the bottom left corner is the anchor point, you put the nail in the lower left corner, then this paper rotation is also around the lower left corner of this point rotation.

To the Cocos Siege of the Lion March HelloWorld

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.