I think, the work is to find a job they like, and then do a lot of years, want to do the Android, do Apple also to do, now want to switch to do games, the direction of the game a lot, select the previous paragraph bar, selected platform Cocos,coocs and 3D, first play 2D bar, write a HelloWorld, It's a new beginning.
Mac under command:
Cocos New Hellowold-p com.jackjiao-l CPP ~/desktop.
The selected language is C + +.
As follows.
Code interpretation:
Classes folder:
AppDelegate.cpp.
AppDelegate.h.
HelloWorldScene.cpp.
HelloWorldScene.h.
Resource folder:
Place the desired resources, slices, fonts, Arial.ttf.
Cocos2d_libs.xcodeproj folder:
This is the Cocos Framework data information under our Xcode.
Frameworks folder:
Is the framework that we use in our projects.
iOS folder:
is a folder under our iOS platform.
Mac: It's the file data we need to use on Mac side.
Products: In iOS, an app file appears when you compile and run. Used to load the phone, test it.
As with iOS, the portal is in:
In Appdelegate, Appdelegate, this entry inherits the Cocos2d::application project.
The project illustrates the inheritance of Cocos, which has several methods:
Imaginary function Appdelegate.
virtual function nitglcontextattrs ():
You can now define only 6 parameters:
To set the OpenGL context property, you can currently only set 6 properties //red,green,blue,alpha,depth,stencil glcontextattrs glcontextattrs = {8, 8, 8, 8, 8}; Glview::setglcontextattrs (Glcontextattrs);
Appli ....
Appli ....
Appli ...
These three functions, like iOS, are not explained.
The applicationdidfinishlaunching call method is used in this area.
Initialize Director
Auto director = Director::getinstance ();
Auto Glview = Director->getopenglview ();
if (!glview) {
#if (Cc_target_platform = = Cc_platform_win32) | | (Cc_target_platform = = Cc_platform_mac) | | (Cc_target_platform = = Cc_platform_linux)
Glview = Glviewimpl::createwithrect ("HelloWorld", cocos2d::rect (0, 0, Designresolutionsize.width, Designresolutionsize.height));
#else
Glview = Glviewimpl::create ("HelloWorld");
#endif
Director->setopenglview (Glview);
}
Turn on display FPS
Director->setdisplaystats (TRUE);
Set FPS. The default value is 1.0/60 if you don ' t call this
Director->setanimationinterval (1.0F/60);
Set The design resolution
Glview->setdesignresolutionsize (Designresolutionsize.width, Designresolutionsize.height, ResolutionPolicy::NO _border);
Auto framesize = Glview->getframesize ();
If the frame ' s height is larger than the height of medium size.
if (Framesize.height > Mediumresolutionsize.height)
{
Director->setcontentscalefactor (MIN (Largeresolutionsize.height/designresolutionsize.height, Largeresolutionsize.width/designresolutionsize.width));
}
If the frame ' s height is larger than the height of small size.
else if (Framesize.height > Smallresolutionsize.height)
{
Director->setcontentscalefactor (MIN (Mediumresolutionsize.height/designresolutionsize.height, Mediumresolutionsize.width/designresolutionsize.width));
}
If the frame ' s height is smaller than the height of medium size.
Else
{
Director->setcontentscalefactor (MIN (Smallresolutionsize.height/designresolutionsize.height, Smallresolutionsize.width/designresolutionsize.width));
}
Register_all_packages ();
Create a scene. It ' s an Autorelease object
Auto scene = Helloworld::createscene ();
Run
Director->runwithscene (Scene);
return true;
Interpret this Code data information:
The HelloWorld of Cocos