ait
#1
I’m using cocos2dx in a MFC win32 application with single document.
But when I resize the window bigger, the cocos2dx rendering sprites goes smaller.
code in OnSize() event:
void CHelloMFCView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
if (m_bCocos2dXInited) {
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(cx, cy, kResolutionExactFit);
}
}
ori.png (403.9 KB)
scaled.png (346.2 KB)
I think you shouldn’t modify design resoultion size.
Instead, you need to modify the Frame size.
Maybe some codes like:
void CHelloMFCView::OnSize(UINT nType, int cx, int cy) {
CView::OnSize(nType, cx, cy);
CCEGLView::sharedOpenGLView()->setFrameSize(cx, cy);
CCSize designSize = CCEGLView::sharedOpenGLView()->getDesignResolutionSize();
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, yourpolicy);
}
ait
#3
Thanks for your help! I look around and found something related, but it did not work for me.
[[http://www.cocos2d-x.org/projects/cocos2d-x/wiki/About_device_orientation]]
btw: It might be a little strange to getDesignResolutionSize(), and set it to the same value…
ait
#4
I wrote some code like this, more or less worked!
SomeView: public CCEGLView {
…
void resize(float width, float height) {
CCEGLViewProtocol::setFrameSize(width, height);
setDesignResolutionSize(width, height, kResolutionShowAll);
CCEGLView::resize(width, height);
}
…
}
ait
#5
The code seems displaying bad here…