Learning Focus: HelloWorld Engineering, COCOS2D-X engine frameworkOpen the HelloWorld project in learning 1 in vs2010, and learn about COCOS2DX's lifecycle and engine framework. 1, the life cycle learning engine has written a life cycle, declaring three virtual functions in AppDelegate.h: applicationdidfinishlaunching: Implementing the Director (Ccdirector) and scene initialization, Applicationdidfinishlaunching---director----Scene layer-> ... applicationdidenterbackground: Call this function when the project enters the background. Applicationwillenterforeground: This function is called when the project enters the front end.
2, engine frame 1) design ideas:
Wizard (Director), scene, Layer, and Sprite (Sprite)
Director (Ccdirector): Class that creates and handle the main Window and manages how and if to execute the Scenes. Switch scenes to control the scene. The director is a singleton pattern.
Scene (Ccscene): Decorate the background. Ccscene is a subclass of Ccnode which is used only as an abstract concept. The scene is a subclass of Ccnode, an abstract idea. Ccscene is also the parent class for all nodes.
Layer (Cclayer): Multiple layers make up a scene and can be nested. Cclayer is a subclass of Ccnode that implements the Toucheventsdelegate protocol. The layer is a subclass of Ccnode and implements the Toucheventsdelegate protocol.
Sprite (Ccsprite): Placed on a layer, displayed in the scene, the specific object is abstracted by the sprite. Ccsprite can is created with an image, or with a sub-rectangle of an image. Sprites can be created with a single image, or they can be created with a sub-matrix.
Action (ccaction): behavior. Base class for Ccaction objects. The base class for the Ccaction object.
Node (Ccnode): The primary element, the basis of all elements. Anything that gets drawn or contains things that get drawn is a ccnode. The most popular ccnodes are:ccscene, Cclayer, Ccsprite,ccmenu. Anything contained is on the basis of Ccnode, the most common is the scene, Layer, Sprite, menu.
Eg: the beginning of "Happy to eliminate music", the UI and buttons are separated by a hierarchical way
2) Framework Scheme:
Node tree, Ccnode
Camera, A Cccamera is used in every ccnode.
Useful to look at the object from different views. The OpenGL Glulookat () function is used to locate the camera. Used to view this object from a different perspective. OpenGL Highway LookAt function can be used to place the camera.
If the object is transformed by any of the scale, rotation or position attributes, then they would override the camera. If this objects are zoomed in/out, rotated, or set position properties, they will overwrite the camera.
Summary: HelloWorld project.
The main function acts as a program entry, and the run function calls the Appdelegate::applicationdidfinishlaunching function to create the director Ccdirector::shareddirector (), The director then runs the scene pdirector->runwithscene (Pscene).
Helloworld::scene (); The scene the director is running is implemented in HelloWorldScene.cpp. Scene creation is empty, so add layers to the scene.
The Add Wizard (ccsprite) in the layer, the sprite has (ccaction) and so on.
PS:C Foundation header file (. h):
write the declaration of a class (including the declaration of members and methods within a class), function prototypes, #define常数等, but generally do not write specific implementations.
: the colon in C + + means:
(1) indicates "domain Operator"
Example: Declares a Class A, Class A declares a member function void F (), but does not give the definition of F in the declaration of the class, so when F is defined outside the class,
will be written as void A::f (), which indicates that the F () function is a member function of class A.
(2) Directly before the global function, which means the global function
Example: In the VC, you can call the API function, in front of the API functions:
(3) Representing reference member functions and variables, scope member operators
Example: System::math::sqrt () is equivalent to System.Math.Sqrt (). For more details, please click here.