zoukankan      html  css  js  c++  java
  • Hello项目分析

    main.cpp  和所有项目一样  程序的主函数

    1 // create the application instance
    2     AppDelegate app;
    3     CCEGLView& eglView = CCEGLView::sharedOpenGLView();
    4     eglView.setViewName("Hello World");
    5     eglView.setFrameSize(480, 320);
    6     // set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
    7     // eglView.setDesignResolutionSize(480, 320);

    第三行意思是界面按照 OpenGL 的标准定义坐标

    第四行设置界面的标题

    第五行是设置尺寸

    第七行我也不知道

    AppDeletag.cpp

     1 // initialize director
     2     CCDirector *pDirector = CCDirector::sharedDirector();
     3     pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView());
     4 
     5     // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices.
     6 //     pDirector->enableRetinaDisplay(true);
     7 
     8     // turn on display FPS
     9     pDirector->setDisplayStats(true);
    10 
    11     // set FPS. the default value is 1.0/60 if you don't call this
    12     pDirector->setAnimationInterval(1.0 / 60);
    13 
    14     // create a scene. it's an autorelease object
    15     CCScene *pScene = HelloWorld::scene();
    16 
    17     // run
    18     pDirector->runWithScene(pScene);

     第六行 用于开启视网膜屏的支持

    第九行 显示左下角FPS 一位小数,最大60

     1 #ifndef __HELLOWORLD_SCENE_H__
     2 #define __HELLOWORLD_SCENE_H__
     3 
     4 #include "cocos2d.h"
     5 
     6 #include "SimpleAudioEngine.h"
     7 
     8 class HelloWorld : public cocos2d::CCLayer
     9 {
    10 public:
    11     // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
    12     virtual bool init();  
    13 
    14     // there's no 'id' in cpp, so we recommand to return the exactly class pointer
    15     static cocos2d::CCScene* scene();
    16     
    17     // a selector callback
    18     void menuCloseCallback(CCObject* pSender);
    19 
    20     // implement the "static node()" method manually
    21     LAYER_CREATE_FUNC(HelloWorld);
    22 };

    第12行 初始化init()方法

    第21行 是cocos2dx的新写法

    LAYER_NODE_FUNC(HelloWorld);//cocos2dx 1.0 的写法
    LAYER_CREATE_FUNC(HelloWorld);//cocos2dx 2.0 的写法
  • 相关阅读:
    ....
    CodeForces 375A(同余)
    POJ 2377 Bad Cowtractors (最小生成树)
    POJ 1258 AgriNet (最小生成树)
    HDU 1016 Prime Ring Problem(全排列)
    HDU 4460 Friend Chains(bfs)
    POJ 2236 Wireless Network(并查集)
    POJ 2100 Graveyard Design(尺取)
    POJ 2110 Mountain Walking(二分/bfs)
    CodeForces 1059B Forgery(模拟)
  • 原文地址:https://www.cnblogs.com/jaoye/p/2635299.html
Copyright © 2011-2022 走看看