Cocos2dx 3.2 + vs2012 + win7 改变面黑色背景的大小

打开AppDeleGate.cpp找到函数applicationDidFinishLaunching,先是通过director = Director::getInstance();获得一个导演实例,然后通过auto glview = director->getOpenGLView();获得一个OpenGLView待渲染的背景层。glview = glview->create("xxx");创建一个名为xxx的OpenGL背景.默认构建glview的背景的frameSize是[960, 640],要改变背景的大小就要设置frameSize;glview->setFrameSize(123, 456);就设置了长为123宽为456的背景。然后导演将设置好的背景添加。

bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    auto director = Director::getInstance(); //创建一个导演
    auto glview = director->getOpenGLView();  //通过导演获得OpenGLView,openGLView就像一个舞台,
	                                          //所有的Scene和图层,精灵,文本,特效等像演员一样都是在此舞台表演的(渲染的)
    if(!glview) {
        glview = GLView::create("My Game");  //设置OpenView的名字
		
		CCLOG("%f, %f", glview->getFrameSize().width, glview->getFrameSize().height);  //默认的FrameSzie是[960,640]
		glview->setFrameSize(480, 320);   //重新设置EGL视图框架尺寸,就是后面黑色背景的大小
		
		director->setOpenGLView(glview);
    }

    // turn on display FPS
    director->setDisplayStats(true);

    // set FPS. the default value is 1.0/60 if you don't call this
    director->setAnimationInterval(1.0 / 60);

    // create a scene. it's an autorelease object
    auto scene = HelloWorldScene::createScene();

    // run
    director->runWithScene(scene);

    return true;
}


不负自己
原文地址:https://www.cnblogs.com/v-BigdoG-v/p/7398653.html