一. 类Director继承关系图
二. 常用方法
(1). 属性相关
1 | //获得当前运行的场景,cocos2dx同时只能运行一个场景 |
2 | Scene* getRunningScene(); |
3 | |
4 | //获取fps值 |
5 | double getAnimationInterval(); |
6 | //设置fps值 |
7 | void setAnimationInterval( double dValue); |
8 | |
9 | //fps是否是显示状态 |
10 | bool isDisplayStats(); |
11 | //设置是否显示fps |
12 | void setDisplayStats( bool bDisplayStats); |
13 | |
14 | //获取每帧秒数 |
15 | float getSecondsPerFrame(); |
16 | |
17 | //获取openGLView |
18 | GLView* getOpenGLView(); |
19 | //设置openGLView |
20 | void setOpenGLView(GLView *pobOpenGLView); |
21 | |
22 | //判断是否暂停 |
23 | bool isPaused(); |
24 | |
25 | //获取调用到现在的所有帧数 |
26 | unsigned int getTotalFrames(); |
27 | |
28 | //判断被替换的场景是否接收到cleanup事件 |
29 | //replace方式会,而push方式则不会 |
30 | bool isSendCleanupToScene( void ); |
(2). 窗口相关
1 | //返回以点为单位openGL视图的大小 |
2 | const Size& getWinSize() const ; |
3 | |
4 | //返回以像素为单位openGL视图的大小 |
5 | Size getWinSizeInPixels() const ; |
6 | |
7 | //返回以点为单位的 OpenGL 视图的可见大小. |
8 | Size getVisibleSize() const ; |
9 | |
10 | //返回以点为单位的 OpenGL 视图的初始化时的可见大小 |
11 | Vec2 getVisibleOrigin() const ; |
12 | |
13 | //UIKit的坐标转换到一个OpenGL坐标 使用当前布局(横向或纵向)有效的(多)触摸坐标 |
14 | Vec2 convertToGL( const Vec2& point); |
15 | |
16 | //一个OpenGL坐标转换到UIKit的坐标 点组成的窗口调用有效的节点上面的点 |
17 | Vec2 convertToUI( const Vec2& point); |
(3). 场景管理相关
1 | //根据给定的场景进入 Director的主循环 只能调用他运行你的第一个场景 |
2 | void runWithScene(Scene *scene); |
3 | |
4 | //暂停执行正在运行的场景中,pushing一个在堆栈上推暂停的场景。 新的场景将被执行. |
5 | void pushScene(Scene *scene); |
6 | |
7 | //从队列中弹出一个场景。 这个场景将替换正在运行的场景. |
8 | void popScene(); |
9 | |
10 | //从队列中弹出所有的场景,直到只有根场景在队列中 这个场景将替换正在运行的场景. |
11 | void popToRootScene(); |
12 | |
13 | //弹出从队列中的所有场景,直到它到达 level. |
14 | void popToSceneStackLevel( int level); |
15 | |
16 | //用一个新的替换正在运行的场景。终止正在运行的场景。 仅在有一个正在运行的场景的时候调用他. |
17 | void replaceScene(Scene *scene); |
18 | |
19 | //结束执行,释放正在运行的场景。 |
20 | void end(); |
21 | |
22 | //暂停正在运行的场景。 |
23 | void pause( void ); |
24 | //恢复暂停的场景 预定的定时器将被再次激活。 “推迟执行”的时间将是0(如果游戏没有暂停) |
25 | void resume(); |