mirror of https://github.com/axmolengine/axmol.git
issue #1405: modify macro names and comment and add getVisibleSize and getVisibleOrigin in CCDirector
This commit is contained in:
parent
cc39dc55f4
commit
c34812567f
|
@ -62,7 +62,7 @@ THE SOFTWARE.
|
||||||
Default: 0,0 (bottom-left corner)
|
Default: 0,0 (bottom-left corner)
|
||||||
*/
|
*/
|
||||||
#ifndef CC_DIRECTOR_STATS_POSITION
|
#ifndef CC_DIRECTOR_STATS_POSITION
|
||||||
#define CC_DIRECTOR_STATS_POSITION CCDirector::sharedDirector()->getOpenGLView()->getVisibleOrigin()
|
#define CC_DIRECTOR_STATS_POSITION CCDirector::sharedDirector()->getVisibleOrigin()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -474,6 +474,30 @@ CCSize CCDirector::getWinSizeInPixels()
|
||||||
return m_obWinSizeInPixels;
|
return m_obWinSizeInPixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CCSize CCDirector::getVisibleSize()
|
||||||
|
{
|
||||||
|
if (m_pobOpenGLView)
|
||||||
|
{
|
||||||
|
return m_pobOpenGLView->getVisibleSize();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return CCSizeZero;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CCPoint CCDirector::getVisibleOrigin()
|
||||||
|
{
|
||||||
|
if (m_pobOpenGLView)
|
||||||
|
{
|
||||||
|
return m_pobOpenGLView->getVisibleOrigin();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return CCPointZero;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CCDirector::reshapeProjection(const CCSize& newWindowSize)
|
void CCDirector::reshapeProjection(const CCSize& newWindowSize)
|
||||||
{
|
{
|
||||||
CC_UNUSED_PARAM(newWindowSize);
|
CC_UNUSED_PARAM(newWindowSize);
|
||||||
|
|
|
@ -166,6 +166,16 @@ public:
|
||||||
*/
|
*/
|
||||||
CCSize getWinSizeInPixels(void);
|
CCSize getWinSizeInPixels(void);
|
||||||
|
|
||||||
|
/** returns visible size of the OpenGL view in points.
|
||||||
|
* the value is equal to getWinSize if don't invoke
|
||||||
|
* CCEGLView::setDesignResolutionSize()
|
||||||
|
*/
|
||||||
|
CCSize getVisibleSize();
|
||||||
|
|
||||||
|
/** returns visible origin of the OpenGL view in points.
|
||||||
|
*/
|
||||||
|
CCPoint getVisibleOrigin();
|
||||||
|
|
||||||
/** changes the projection size */
|
/** changes the projection size */
|
||||||
void reshapeProjection(const CCSize& newWindowSize);
|
void reshapeProjection(const CCSize& newWindowSize);
|
||||||
|
|
||||||
|
|
|
@ -72,12 +72,12 @@ void CCEGLViewProtocol::setDesignResolutionSize(float width, float height, Resol
|
||||||
m_fXScale = (float)m_obScreenSize.width / m_obDesignResolutionSize.width;
|
m_fXScale = (float)m_obScreenSize.width / m_obDesignResolutionSize.width;
|
||||||
m_fYScale = (float)m_obScreenSize.height / m_obDesignResolutionSize.height;
|
m_fYScale = (float)m_obScreenSize.height / m_obDesignResolutionSize.height;
|
||||||
|
|
||||||
if (resolutionPolicy == kResolutionScaleFullScreen)
|
if (resolutionPolicy == kCCResolutionNoBorder)
|
||||||
{
|
{
|
||||||
m_fXScale = m_fYScale = MAX(m_fXScale, m_fYScale);
|
m_fXScale = m_fYScale = MAX(m_fXScale, m_fYScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resolutionPolicy == kResolutionScaleNotFullScreen)
|
if (resolutionPolicy == kCCResolutionShowAll)
|
||||||
{
|
{
|
||||||
m_fXScale = m_fYScale = MIN(m_fXScale, m_fYScale);
|
m_fXScale = m_fYScale = MIN(m_fXScale, m_fYScale);
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ void CCEGLViewProtocol::setSize(float width, float height)
|
||||||
|
|
||||||
CCSize CCEGLViewProtocol::getVisibleSize()
|
CCSize CCEGLViewProtocol::getVisibleSize()
|
||||||
{
|
{
|
||||||
if (m_eResolutionPolicy == kResolutionScaleFullScreen)
|
if (m_eResolutionPolicy == kCCResolutionNoBorder)
|
||||||
{
|
{
|
||||||
return CCSizeMake(m_obScreenSize.width/m_fXScale, m_obScreenSize.height/m_fYScale);
|
return CCSizeMake(m_obScreenSize.width/m_fXScale, m_obScreenSize.height/m_fYScale);
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ CCSize CCEGLViewProtocol::getVisibleSize()
|
||||||
|
|
||||||
CCPoint CCEGLViewProtocol::getVisibleOrigin()
|
CCPoint CCEGLViewProtocol::getVisibleOrigin()
|
||||||
{
|
{
|
||||||
if (m_eResolutionPolicy == kResolutionScaleFullScreen)
|
if (m_eResolutionPolicy == kCCResolutionNoBorder)
|
||||||
{
|
{
|
||||||
return CCPointMake((m_obDesignResolutionSize.width - m_obScreenSize.width/m_fXScale)/2,
|
return CCPointMake((m_obDesignResolutionSize.width - m_obScreenSize.width/m_fXScale)/2,
|
||||||
(m_obDesignResolutionSize.height - m_obScreenSize.height/m_fYScale)/2);
|
(m_obDesignResolutionSize.height - m_obScreenSize.height/m_fYScale)/2);
|
||||||
|
|
|
@ -5,12 +5,15 @@
|
||||||
|
|
||||||
enum ResolutionPolicy
|
enum ResolutionPolicy
|
||||||
{
|
{
|
||||||
// the output will fill the screen, scale of x and y may be different
|
// The entire application is visible in the specified area without trying to preserve the original aspect ratio.
|
||||||
kResolutionFullScreen,
|
// Distortion can occur, and the application may appear stretched or compressed.
|
||||||
// the output will fill the screen, scale of x and y is the same
|
kCCResolutionExactFit,
|
||||||
kResolutionScaleFullScreen,
|
// The entire application fills the specified area, without distortion but possibly with some cropping,
|
||||||
// scale of x and y is the same, there may be black block in x or y coordinate
|
// while maintaining the original aspect ratio of the application.
|
||||||
kResolutionScaleNotFullScreen,
|
kCCResolutionNoBorder,
|
||||||
|
// The entire application is visible in the specified area without distortion while maintaining the original
|
||||||
|
// aspect ratio of the application. Borders can appear on two sides of the application.
|
||||||
|
kCCResolutionShowAll,
|
||||||
|
|
||||||
kResolutionUnKnown,
|
kResolutionUnKnown,
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,7 +24,7 @@ bool AppDelegate::applicationDidFinishLaunching() {
|
||||||
CCFileUtils::sharedFileUtils()->setResourceDirectory("iphonehd");
|
CCFileUtils::sharedFileUtils()->setResourceDirectory("iphonehd");
|
||||||
|
|
||||||
// don't enable retina because we don't have ipad hd resource
|
// don't enable retina because we don't have ipad hd resource
|
||||||
CCEGLView::sharedOpenGLView().setDesignResolutionSize(960, 640, kResolutionScaleFullScreen);
|
CCEGLView::sharedOpenGLView().setDesignResolutionSize(960, 640, kCCResolutionNoBorder);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -32,20 +32,22 @@ bool AppDelegate::applicationDidFinishLaunching() {
|
||||||
|
|
||||||
if (pDirector->enableRetinaDisplay(true))
|
if (pDirector->enableRetinaDisplay(true))
|
||||||
{
|
{
|
||||||
// iphone
|
// iphone hd
|
||||||
CCFileUtils::sharedFileUtils()->setResourceDirectory("iphonehd");
|
CCFileUtils::sharedFileUtils()->setResourceDirectory("iphonehd");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (isIos())
|
if (isIos())
|
||||||
{
|
{
|
||||||
|
// iphone
|
||||||
CCFileUtils::sharedFileUtils()->setResourceDirectory("iphone");
|
CCFileUtils::sharedFileUtils()->setResourceDirectory("iphone");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CCFileUtils::sharedFileUtils()->setResourceDirectory("iphonehd");
|
|
||||||
// android or other platform, use hd resource
|
// android or other platform, use hd resource
|
||||||
CCEGLView::sharedOpenGLView().setDesignResolutionSize(960, 640, kResolutionScaleFullScreen);
|
|
||||||
|
CCFileUtils::sharedFileUtils()->setResourceDirectory("iphonehd");
|
||||||
|
CCEGLView::sharedOpenGLView().setDesignResolutionSize(960, 640, kCCResolutionNoBorder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,8 @@ bool HelloWorld::init()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSize visibleSize = CCDirector::sharedDirector()->getOpenGLView()->getVisibleSize();
|
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
|
||||||
CCPoint origin = CCDirector::sharedDirector()->getOpenGLView()->getVisibleOrigin();
|
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
|
||||||
|
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
// 2. add a menu item with "X" image, which is clicked to quit the program
|
// 2. add a menu item with "X" image, which is clicked to quit the program
|
||||||
|
|
Loading…
Reference in New Issue