首页 > 其他 > 详细

cocos2d-x之helloworld

时间:2014-03-25 14:50:58      阅读:406      评论:0      收藏:0      [点我收藏+]

配置:在VS2008平台下,

1,在github上下载最新版,运行“build-win32.bat”脚本。

2,点击内置的helloworld,出错。

3,更新显卡驱动,重新运行。成功。

4,运行“install - templates-msvc.bat”安装VS向导,然后就可以建立项目了。



研究helloworld:

1,打开helloworld的工程,

bubuko.com,布布扣

里面主要是相关的类和主函数。

2,然后又打开helloworld文件夹,

bubuko.com,布布扣

工程的布置就一目了然了。

3,看main.cpp:

#include "main.h"
#include "../Classes/AppDelegate.h"
#include "CCEGLView.h"

USING_NS_CC;

int APIENTRY _tWinMain(HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
                       LPTSTR    lpCmdLine,
                       int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

    // create the application instance
    AppDelegate app;
    CCEGLView& eglView = CCEGLView::sharedOpenGLView();
    eglView.setViewName("Hello World");
    eglView.setFrameSize(480, 320);
    // set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
    // eglView.setDesignResolutionSize(480, 320);
    return CCApplication::sharedApplication().run();
}


很亲切的感觉,建立窗口名称,调整窗口大小,应用程序循环,跟opengl很像,虽然名字不一样,但是也能猜出来。

其中AppDelegate是最主要的类,管理着整个应用程序:

bubuko.com,布布扣
基本的实现方式跟opengl都是很像的,所以也不难看懂。

CCEGLView是整个程序的窗口类,应该就类似于glut窗口库子集的那种基本调度的。


然后我就去看了一下几个主类的定义。

点击打开链接













cocos2d-x之helloworld,布布扣,bubuko.com

cocos2d-x之helloworld

原文:http://blog.csdn.net/modiziri/article/details/22037725

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!