kResolutionShowAll好像没起作用嘛。
无论原来的helloworld图片还是通过cocostudio编辑后加载的UILayer,都没法适应屏幕。。如截图:
main的:
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(" COCO! ");
eglView->setFrameSize(1280,720);
return CCApplication::sharedApplication()->run();
}
AppDelegate.cpp下的:
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
CCDirector* pDirector = CCDirector::sharedDirector();
CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
pDirector->setOpenGLView(pEGLView);
//CCSize frameSize = pEGLView->getFrameSize();
CCSize winsize = CCDirector::sharedDirector()->getWinSize();
pEGLView->setDesignResolutionSize(winsize.width,winsize.height,kResolutionShowAll);
float ratio = winsize.width / winsize.height;
// turn on display FPS
pDirector->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don’t call this
pDirector->setAnimationInterval(1.0 / 60);
// create a scene. it’s an autorelease object
CCScene *pScene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
return true;
}
HelloWorldScene.cpp下的:
bool HelloWorld::init()
{
if ( !CCLayer::init() )
{
return false;
}
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
// add a "close" icon to exit the progress. it's an autorelease object
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(HelloWorld::menuCloseCallback));
pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
origin.y + pCloseItem->getContentSize().height/2));
// create menu, it’s an autorelease object
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
pMenu->setPosition(CCPointZero);
this->addChild(pMenu, 1);
// add “HelloWorld” splash screen"
CCSprite* pSprite = CCSprite::create(“HelloWorld.png”);
pSprite->setPosition(ccp(visibleSize.width/2, visibleSize.height/2));
this->addChild(pSprite, 0);
UILayer* ul = UILayer::create();
ul->addWidget(GUIReader::shareReader()->widgetFromJsonFile(“cocouitest/Export/cocouitest_1/cocouitest_1.json”));
this->addChild(ul);
return true;
}
