CCDirector导演类

来源:互联网 发布:安庆市网络教研平台 编辑:程序博客网 时间:2024/04/28 16:53

  1。访问和改变场景

  2。应用核心loop

  3.  绑定和访问窗口

  4。处理自动回收对象

  5。处理事件消息转发

  6。初始化各种管理器

 7。处理在各Node的计划任务执行

 8.在平台窗口绘图和opengl之间转换坐标

以下是CCDirector::init方法

bool CCDirector::init(void)
{
    CCLOG("cocos2d: %s", cocos2dVersion());
    
    // scenes 场景相关
    m_pRunningScene = NULL;
    m_pNextScene = NULL;

    m_pNotificationNode = NULL;

    m_dOldAnimationInterval = m_dAnimationInterval = 1.0 / kDefaultFPS;    
    m_pobScenesStack = new CCArray();
    m_pobScenesStack->init();

    // Set default projection (3D)
    m_eProjection = kCCDirectorProjectionDefault;

    // projection delegate if "Custom" projection is used
    m_pProjectionDelegate = NULL;

    // FPS  相关
    m_fAccumDt = 0.0f;
    m_fFrameRate = 0.0f;
    m_pFPSLabel = NULL;
    m_pSPFLabel = NULL;
    m_pDrawsLabel = NULL;
    m_bDisplayStats = false;
    m_uTotalFrames = m_uFrames = 0;
    m_pszFPS = new char[10];
    m_pLastUpdate = new struct cc_timeval();

    // paused ? 暂停
    m_bPaused = false;
   
    // purge ?
    m_bPurgeDirecotorInNextLoop = false;

    m_obWinSizeInPixels = m_obWinSizeInPoints = CCSizeZero;   

    m_pobOpenGLView = NULL;

    m_fContentScaleFactor = 1.0f;
    m_bIsContentScaleSupported = false;

    // scheduler 计划任务
    m_pScheduler = new CCScheduler();
    // action manager 动作管理器
    m_pActionManager = new CCActionManager();
    m_pScheduler->scheduleUpdateForTarget(m_pActionManager, kCCPrioritySystem, false);
    // touchDispatcher 触摸消息分发器
    m_pTouchDispatcher = new CCTouchDispatcher();
    m_pTouchDispatcher->init();

    // KeypadDispatcher 按键消息分发器
    m_pKeypadDispatcher = new CCKeypadDispatcher();

    // Accelerometer  重力加速器
    m_pAccelerometer = new CCAccelerometer();

    // create autorelease pool 对象自动释放池管理器
    CCPoolManager::sharedPoolManager()->push();

    return true;
}

原创粉丝点击