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)
|
||||
*/
|
||||
#ifndef CC_DIRECTOR_STATS_POSITION
|
||||
#define CC_DIRECTOR_STATS_POSITION CCDirector::sharedDirector()->getOpenGLView()->getVisibleOrigin()
|
||||
#define CC_DIRECTOR_STATS_POSITION CCDirector::sharedDirector()->getVisibleOrigin()
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
@ -474,6 +474,30 @@ CCSize CCDirector::getWinSizeInPixels()
|
|||
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)
|
||||
{
|
||||
CC_UNUSED_PARAM(newWindowSize);
|
||||
|
|
|
@ -165,6 +165,16 @@ public:
|
|||
/** returns the size of the OpenGL view in pixels.
|
||||
*/
|
||||
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 */
|
||||
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_fYScale = (float)m_obScreenSize.height / m_obDesignResolutionSize.height;
|
||||
|
||||
if (resolutionPolicy == kResolutionScaleFullScreen)
|
||||
if (resolutionPolicy == kCCResolutionNoBorder)
|
||||
{
|
||||
m_fXScale = m_fYScale = MAX(m_fXScale, m_fYScale);
|
||||
}
|
||||
|
||||
if (resolutionPolicy == kResolutionScaleNotFullScreen)
|
||||
if (resolutionPolicy == kCCResolutionShowAll)
|
||||
{
|
||||
m_fXScale = m_fYScale = MIN(m_fXScale, m_fYScale);
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ void CCEGLViewProtocol::setSize(float width, float height)
|
|||
|
||||
CCSize CCEGLViewProtocol::getVisibleSize()
|
||||
{
|
||||
if (m_eResolutionPolicy == kResolutionScaleFullScreen)
|
||||
if (m_eResolutionPolicy == kCCResolutionNoBorder)
|
||||
{
|
||||
return CCSizeMake(m_obScreenSize.width/m_fXScale, m_obScreenSize.height/m_fYScale);
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ CCSize CCEGLViewProtocol::getVisibleSize()
|
|||
|
||||
CCPoint CCEGLViewProtocol::getVisibleOrigin()
|
||||
{
|
||||
if (m_eResolutionPolicy == kResolutionScaleFullScreen)
|
||||
if (m_eResolutionPolicy == kCCResolutionNoBorder)
|
||||
{
|
||||
return CCPointMake((m_obDesignResolutionSize.width - m_obScreenSize.width/m_fXScale)/2,
|
||||
(m_obDesignResolutionSize.height - m_obScreenSize.height/m_fYScale)/2);
|
||||
|
|
|
@ -5,12 +5,15 @@
|
|||
|
||||
enum ResolutionPolicy
|
||||
{
|
||||
// the output will fill the screen, scale of x and y may be different
|
||||
kResolutionFullScreen,
|
||||
// the output will fill the screen, scale of x and y is the same
|
||||
kResolutionScaleFullScreen,
|
||||
// scale of x and y is the same, there may be black block in x or y coordinate
|
||||
kResolutionScaleNotFullScreen,
|
||||
// The entire application is visible in the specified area without trying to preserve the original aspect ratio.
|
||||
// Distortion can occur, and the application may appear stretched or compressed.
|
||||
kCCResolutionExactFit,
|
||||
// The entire application fills the specified area, without distortion but possibly with some cropping,
|
||||
// while maintaining the original aspect ratio of the application.
|
||||
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,
|
||||
};
|
||||
|
|
|
@ -24,7 +24,7 @@ bool AppDelegate::applicationDidFinishLaunching() {
|
|||
CCFileUtils::sharedFileUtils()->setResourceDirectory("iphonehd");
|
||||
|
||||
// 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
|
||||
{
|
||||
|
@ -32,20 +32,22 @@ bool AppDelegate::applicationDidFinishLaunching() {
|
|||
|
||||
if (pDirector->enableRetinaDisplay(true))
|
||||
{
|
||||
// iphone
|
||||
// iphone hd
|
||||
CCFileUtils::sharedFileUtils()->setResourceDirectory("iphonehd");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isIos())
|
||||
{
|
||||
// iphone
|
||||
CCFileUtils::sharedFileUtils()->setResourceDirectory("iphone");
|
||||
}
|
||||
else
|
||||
{
|
||||
CCFileUtils::sharedFileUtils()->setResourceDirectory("iphonehd");
|
||||
// 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;
|
||||
}
|
||||
|
||||
CCSize visibleSize = CCDirector::sharedDirector()->getOpenGLView()->getVisibleSize();
|
||||
CCPoint origin = CCDirector::sharedDirector()->getOpenGLView()->getVisibleOrigin();
|
||||
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
|
||||
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
|
||||
|
||||
/////////////////////////////
|
||||
// 2. add a menu item with "X" image, which is clicked to quit the program
|
||||
|
|
Loading…
Reference in New Issue