Merge branch 'iss1405_multi_resolution' of https://github.com/minggo/cocos2d-x into minggo_res

This commit is contained in:
James Chen 2012-08-09 10:53:14 +08:00
commit af1b58bea6
35 changed files with 392 additions and 621 deletions

View File

@ -56,6 +56,15 @@ THE SOFTWARE.
#include "CCEGLView.h" #include "CCEGLView.h"
#include <string> #include <string>
/**
Position of the FPS
Default: 0,0 (bottom-left corner)
*/
#ifndef CC_DIRECTOR_STATS_POSITION
#define CC_DIRECTOR_STATS_POSITION CCDirector::sharedDirector()->getVisibleOrigin()
#endif
using namespace std; using namespace std;
unsigned int g_uNumberOfDraws = 0; unsigned int g_uNumberOfDraws = 0;
@ -465,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);
@ -733,16 +766,17 @@ void CCDirector::createStatsLabel()
{ {
if( m_pFPSLabel && m_pSPFLabel ) if( m_pFPSLabel && m_pSPFLabel )
{ {
CCTexture2D *texture = m_pFPSLabel->getTexture(); //CCTexture2D *texture = m_pFPSLabel->getTexture();
CC_SAFE_RELEASE_NULL(m_pFPSLabel); CC_SAFE_RELEASE_NULL(m_pFPSLabel);
CC_SAFE_RELEASE_NULL(m_pSPFLabel); CC_SAFE_RELEASE_NULL(m_pSPFLabel);
CC_SAFE_RELEASE_NULL(m_pDrawsLabel); CC_SAFE_RELEASE_NULL(m_pDrawsLabel);
CCTextureCache::sharedTextureCache()->removeTexture(texture); // CCTextureCache::sharedTextureCache()->removeTexture(texture);
CCFileUtils::sharedFileUtils()->purgeCachedEntries(); CCFileUtils::sharedFileUtils()->purgeCachedEntries();
} }
/*
CCTexture2DPixelFormat currentFormat = CCTexture2D::defaultAlphaPixelFormat(); CCTexture2DPixelFormat currentFormat = CCTexture2D::defaultAlphaPixelFormat();
CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444); CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444);
m_pFPSLabel = new CCLabelAtlas(); m_pFPSLabel = new CCLabelAtlas();
@ -751,12 +785,23 @@ void CCDirector::createStatsLabel()
m_pSPFLabel->initWithString("0.000", "fps_images.png", 12, 32, '.'); m_pSPFLabel->initWithString("0.000", "fps_images.png", 12, 32, '.');
m_pDrawsLabel = new CCLabelAtlas(); m_pDrawsLabel = new CCLabelAtlas();
m_pDrawsLabel->initWithString("000", "fps_images.png", 12, 32, '.'); m_pDrawsLabel->initWithString("000", "fps_images.png", 12, 32, '.');
*/
m_pFPSLabel = CCLabelTTF::create("00.0", "Arial", 24);
m_pFPSLabel->retain();
m_pSPFLabel = CCLabelTTF::create("0.000", "Arial", 24);
m_pSPFLabel->retain();
m_pDrawsLabel = CCLabelTTF::create("000", "Arial", 24);
m_pDrawsLabel->retain();
CCTexture2D::setDefaultAlphaPixelFormat(currentFormat); //CCTexture2D::setDefaultAlphaPixelFormat(currentFormat);
m_pDrawsLabel->setPosition( ccpAdd( ccp(0,34), CC_DIRECTOR_STATS_POSITION ) );
m_pSPFLabel->setPosition( ccpAdd( ccp(0,17), CC_DIRECTOR_STATS_POSITION ) ); CCSize contentSize = m_pDrawsLabel->getContentSize();
m_pFPSLabel->setPosition( CC_DIRECTOR_STATS_POSITION ); m_pDrawsLabel->setPosition(ccpAdd(ccp(contentSize.width/2, contentSize.height/2 + 40), CC_DIRECTOR_STATS_POSITION));
contentSize = m_pSPFLabel->getContentSize();
m_pSPFLabel->setPosition(ccpAdd(ccp(contentSize.width/2, contentSize.height/2 + 20), CC_DIRECTOR_STATS_POSITION));
contentSize = m_pFPSLabel->getContentSize();
m_pFPSLabel->setPosition(ccpAdd(ccp(contentSize.width/2, contentSize.height/2), CC_DIRECTOR_STATS_POSITION));
} }
@ -766,16 +811,7 @@ void CCDirector::createStatsLabel()
void CCDirector::updateContentScaleFactor() void CCDirector::updateContentScaleFactor()
{ {
// [openGLView responseToSelector:@selector(setContentScaleFactor)] m_bIsContentScaleSupported = m_pobOpenGLView->setContentScaleFactor(m_fContentScaleFactor);
if (m_pobOpenGLView->canSetContentScaleFactor())
{
m_pobOpenGLView->setContentScaleFactor(m_fContentScaleFactor);
m_bIsContentScaleSupported = true;
}
else
{
CCLOG("cocos2d: setContentScaleFactor:'is not supported on this device");
}
} }
bool CCDirector::enableRetinaDisplay(bool enabled) bool CCDirector::enableRetinaDisplay(bool enabled)
@ -791,15 +827,8 @@ bool CCDirector::enableRetinaDisplay(bool enabled)
{ {
return false; return false;
} }
// setContentScaleFactor is not supported if (! m_pobOpenGLView->enableRetina())
if (! m_pobOpenGLView->canSetContentScaleFactor())
{
return false;
}
// SD device
if (m_pobOpenGLView->getMainScreenScale() == 1.0)
{ {
return false; return false;
} }

View File

@ -34,6 +34,7 @@ THE SOFTWARE.
#include "cocoa/CCArray.h" #include "cocoa/CCArray.h"
#include "CCGL.h" #include "CCGL.h"
#include "kazmath/mat4.h" #include "kazmath/mat4.h"
#include "label_nodes/CCLabelTTF.h"
NS_CC_BEGIN NS_CC_BEGIN
@ -164,6 +165,16 @@ public:
/** returns the size of the OpenGL view in pixels. /** returns the size of the OpenGL view in pixels.
*/ */
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);
@ -344,9 +355,9 @@ protected:
float m_fAccumDt; float m_fAccumDt;
float m_fFrameRate; float m_fFrameRate;
CCLabelAtlas *m_pFPSLabel; CCLabelTTF *m_pFPSLabel;
CCLabelAtlas *m_pSPFLabel; CCLabelTTF *m_pSPFLabel;
CCLabelAtlas *m_pDrawsLabel; CCLabelTTF *m_pDrawsLabel;
/** Whether or not the Director is paused */ /** Whether or not the Director is paused */
bool m_bPaused; bool m_bPaused;
@ -404,7 +415,9 @@ protected:
WatcherCallbackFun m_pWatcherFun; WatcherCallbackFun m_pWatcherFun;
void *m_pWatcherSender; void *m_pWatcherSender;
// CCEGLViewProtocol will recreate stats labels to fit visible rect
friend class CCEGLViewProtocol;
}; };
/** /**

View File

@ -76,16 +76,6 @@ To enabled set it to 1. Disabled by default.
#define CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL 0 #define CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL 0
#endif #endif
/** @def CC_DIRECTOR_STATS_POSITION
Position of the FPS
Default: 0,0 (bottom-left corner)
*/
#ifndef CC_DIRECTOR_STATS_POSITION
#define CC_DIRECTOR_STATS_POSITION ccp(0,0)
#endif
/** @def CC_DIRECTOR_FPS_INTERVAL /** @def CC_DIRECTOR_FPS_INTERVAL
Senconds between FPS updates. Senconds between FPS updates.
0.5 seconds, means that the FPS number will be updated every 0.5 seconds. 0.5 seconds, means that the FPS number will be updated every 0.5 seconds.

View File

@ -305,22 +305,6 @@ typedef struct _ccBlendFunc
GLenum dst; GLenum dst;
} ccBlendFunc; } ccBlendFunc;
//! ccResolutionType
typedef enum
{
//! Unknonw resolution type
kCCResolutionUnknown,
//! iPhone resolution type
kCCResolutioniPhone,
//! RetinaDisplay resolution type
kCCResolutioniPhoneRetinaDisplay,
//! iPad resolution type
kCCResolutioniPad,
//! iPad Retina Display resolution type
kCCResolutioniPadRetinaDisplay,
} ccResolutionType;
// XXX: If any of these enums are edited and/or reordered, udpate CCTexture2D.m // XXX: If any of these enums are edited and/or reordered, udpate CCTexture2D.m
//! Vertical text alignment type //! Vertical text alignment type
typedef enum typedef enum

View File

@ -293,32 +293,6 @@ void CCLabelTTF::updateTexture()
m_pFontName->c_str(), m_pFontName->c_str(),
m_fFontSize * CC_CONTENT_SCALE_FACTOR()); m_fFontSize * CC_CONTENT_SCALE_FACTOR());
} }
// iPad ?
//if( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ) {
if (CCApplication::sharedApplication().isIpad())
{
if (CC_CONTENT_SCALE_FACTOR() == 2)
{
tex->setResolutionType(kCCResolutioniPadRetinaDisplay);
}
else
{
tex->setResolutionType(kCCResolutioniPad);
}
}
// iPhone ?
else
{
if (CC_CONTENT_SCALE_FACTOR() == 2)
{
tex->setResolutionType(kCCResolutioniPhoneRetinaDisplay);
}
else
{
tex->setResolutionType(kCCResolutioniPhone);
}
}
this->setTexture(tex); this->setTexture(tex);
tex->release(); tex->release();

View File

@ -50,6 +50,7 @@ public:
virtual ccLanguageType getCurrentLanguage() = 0; virtual ccLanguageType getCurrentLanguage() = 0;
virtual bool isIpad() { return false; } virtual bool isIpad() { return false; }
virtual bool isIos() { return false; }
}; };

View File

@ -43,11 +43,13 @@ static void removeUsedIndexBit(int index)
} }
CCEGLViewProtocol::CCEGLViewProtocol() CCEGLViewProtocol::CCEGLViewProtocol()
: m_bNeedScale(false) : m_pDelegate(NULL)
, m_pDelegate(NULL) , m_fScreenScaleFactor(1.0f)
, m_fScreenScaleFactor(1.0f) , m_fYScale(1.0f)
, m_fXScale(1.0f)
, m_bIsRetinaEnabled(false)
, m_eResolutionPolicy(kResolutionUnKnown)
{ {
strncpy(m_szViewName, "Cocos2d-x Game", sizeof(m_szViewName));
} }
CCEGLViewProtocol::~CCEGLViewProtocol() CCEGLViewProtocol::~CCEGLViewProtocol()
@ -55,57 +57,85 @@ CCEGLViewProtocol::~CCEGLViewProtocol()
} }
void CCEGLViewProtocol::setFrameSize(float width, float height) void CCEGLViewProtocol::setDesignResolutionSize(float width, float height, ResolutionPolicy resolutionPolicy)
{
m_sSizeInPixel.setSize(width, height);
m_rcViewPort.size.setSize(width, height);
}
CCSize CCEGLViewProtocol::getFrameSize()
{
return m_sSizeInPixel;
}
void CCEGLViewProtocol::setDesignResolutionSize(float width, float height)
{ {
CCAssert(m_bIsRetinaEnabled == false, "can not enable retina while set design resolution size!");
CCAssert(resolutionPolicy != kResolutionUnKnown, "should set resolutionPolicy");
if (width == 0.0f || height == 0.0f) if (width == 0.0f || height == 0.0f)
{ {
return; return;
} }
m_sSizeInPoint.setSize(width, height); m_obDesignResolutionSize.setSize(width, height);
m_fXScale = (float)m_obScreenSize.width / m_obDesignResolutionSize.width;
m_fYScale = (float)m_obScreenSize.height / m_obDesignResolutionSize.height;
if (resolutionPolicy == kCCResolutionNoBorder)
{
m_fXScale = m_fYScale = MAX(m_fXScale, m_fYScale);
}
if (resolutionPolicy == kCCResolutionShowAll)
{
m_fXScale = m_fYScale = MIN(m_fXScale, m_fYScale);
}
// calculate the factor and the rect of viewport // calculate the rect of viewport
m_fScreenScaleFactor = MIN((float)m_sSizeInPixel.width / m_sSizeInPoint.width, float viewPortW = m_obDesignResolutionSize.width * m_fXScale;
(float)m_sSizeInPixel.height / m_sSizeInPoint.height); float viewPortH = m_obDesignResolutionSize.height * m_fYScale;
float viewPortW = m_sSizeInPoint.width * m_fScreenScaleFactor;
float viewPortH = m_sSizeInPoint.height * m_fScreenScaleFactor;
m_rcViewPort.setRect((m_sSizeInPixel.width - viewPortW) / 2, (m_sSizeInPixel.height - viewPortH) / 2, viewPortW, viewPortH); m_obViewPortRect.setRect((m_obScreenSize.width - viewPortW) / 2, (m_obScreenSize.height - viewPortH) / 2, viewPortW, viewPortH);
m_eResolutionPolicy = resolutionPolicy;
//setViewPortInPoints(0, 0,m_obScreenSize.width, m_obScreenSize.height);
// reset director's member vaviables to fit visible rect
CCDirector::sharedDirector()->createStatsLabel();
CCDirector::sharedDirector()->m_obWinSizeInPoints = CCDirector::sharedDirector()->m_obWinSizeInPixels = getSize();
CCDirector::sharedDirector()->setGLDefaultValues();
}
CCLOG("m_fScreenScaleFactor = %f", m_fScreenScaleFactor); bool CCEGLViewProtocol::enableRetina()
m_bNeedScale = true; {
return false;
} }
CCSize CCEGLViewProtocol::getSize() CCSize CCEGLViewProtocol::getSize()
{ {
CCSize size; return m_obDesignResolutionSize;
if (m_bNeedScale)
{
// retina and scale mode can't be opened at the same time
CCAssert(CC_CONTENT_SCALE_FACTOR() == 1.0f, "retina and scale mode can't be opened at the same time!");
size.setSize(m_sSizeInPoint.width, m_sSizeInPoint.height);
}
else
{
size.setSize(m_sSizeInPixel.width, m_sSizeInPixel.height);
}
return size;
} }
CCRect CCEGLViewProtocol::getViewPort() void CCEGLViewProtocol::setSize(float width, float height)
{ {
return m_rcViewPort; m_obDesignResolutionSize = m_obScreenSize = CCSizeMake(width, height);
}
CCSize CCEGLViewProtocol::getVisibleSize()
{
if (m_eResolutionPolicy == kCCResolutionNoBorder)
{
return CCSizeMake(m_obScreenSize.width/m_fXScale, m_obScreenSize.height/m_fYScale);
}
else
{
return m_obDesignResolutionSize;
}
}
CCPoint CCEGLViewProtocol::getVisibleOrigin()
{
if (m_eResolutionPolicy == kCCResolutionNoBorder)
{
return CCPointMake((m_obDesignResolutionSize.width - m_obScreenSize.width/m_fXScale)/2,
(m_obDesignResolutionSize.height - m_obScreenSize.height/m_fYScale)/2);
}
else
{
return CCPointZero;
}
} }
void CCEGLViewProtocol::setTouchDelegate(EGLTouchDelegate * pDelegate) void CCEGLViewProtocol::setTouchDelegate(EGLTouchDelegate * pDelegate)
@ -118,74 +148,25 @@ float CCEGLViewProtocol::getScreenScaleFactor()
return m_fScreenScaleFactor; return m_fScreenScaleFactor;
} }
bool CCEGLViewProtocol::canSetContentScaleFactor() bool CCEGLViewProtocol::setContentScaleFactor(float contentScaleFactor)
{ {
return false; return false;
} }
void CCEGLViewProtocol::setContentScaleFactor(float contentScaleFactor)
{
m_fScreenScaleFactor = contentScaleFactor;
}
void CCEGLViewProtocol::setViewPortInPoints(float x , float y , float w , float h) void CCEGLViewProtocol::setViewPortInPoints(float x , float y , float w , float h)
{ {
if (m_bNeedScale) glViewport((GLint)(x * m_fXScale + m_obViewPortRect.origin.x),
{ (GLint)(y * m_fYScale + m_obViewPortRect.origin.y),
CCAssert(CC_CONTENT_SCALE_FACTOR() == 1.0f, "retina and scale mode can't be opened at the same time!"); (GLsizei)(w * m_fXScale),
float factor = m_fScreenScaleFactor / CC_CONTENT_SCALE_FACTOR(); (GLsizei)(h * m_fYScale));
glViewport((GLint)(x * factor + m_rcViewPort.origin.x),
(GLint)(y * factor + m_rcViewPort.origin.y),
(GLsizei)(w * factor),
(GLsizei)(h * factor));
}
else
{
glViewport(
(GLint)(x*CC_CONTENT_SCALE_FACTOR()),
(GLint)(y*CC_CONTENT_SCALE_FACTOR()),
(GLsizei)(w*CC_CONTENT_SCALE_FACTOR()),
(GLsizei)(h*CC_CONTENT_SCALE_FACTOR()));
}
} }
void CCEGLViewProtocol::setScissorInPoints(float x , float y , float w , float h) void CCEGLViewProtocol::setScissorInPoints(float x , float y , float w , float h)
{ {
if (m_bNeedScale) glScissor((GLint)(x * m_fXScale + m_obViewPortRect.origin.x),
{ (GLint)(y * m_fYScale + m_obViewPortRect.origin.y),
CCAssert(CC_CONTENT_SCALE_FACTOR() == 1.0f, "retina and scale mode can't be opened at the same time!"); (GLsizei)(w * m_fXScale),
float factor = m_fScreenScaleFactor / CC_CONTENT_SCALE_FACTOR(); (GLsizei)(h * m_fYScale));
glScissor((GLint)(x * factor + m_rcViewPort.origin.x),
(GLint)(y * factor + m_rcViewPort.origin.y),
(GLsizei)(w * factor),
(GLsizei)(h * factor));
}
else
{
glScissor(
(GLint)(x * CC_CONTENT_SCALE_FACTOR()),
(GLint)(y * CC_CONTENT_SCALE_FACTOR()),
(GLsizei)(w * CC_CONTENT_SCALE_FACTOR()),
(GLsizei)(h * CC_CONTENT_SCALE_FACTOR()));
}
}
float CCEGLViewProtocol::getMainScreenScale()
{
return -1.0f;
}
void CCEGLViewProtocol::setViewName(const char* pszViewName)
{
if (pszViewName != NULL && strlen(pszViewName) > 0)
{
strncpy(m_szViewName, pszViewName, sizeof(m_szViewName));
}
}
const char* CCEGLViewProtocol::getViewName()
{
return m_szViewName;
} }
void CCEGLViewProtocol::handleTouchesBegin(int num, int ids[], float xs[], float ys[]) void CCEGLViewProtocol::handleTouchesBegin(int num, int ids[], float xs[], float ys[])
@ -212,15 +193,21 @@ void CCEGLViewProtocol::handleTouchesBegin(int num, int ids[], float xs[], float
} }
CCTouch* pTouch = s_pTouches[nUnusedIndex] = new CCTouch(); CCTouch* pTouch = s_pTouches[nUnusedIndex] = new CCTouch();
if (m_bNeedScale) if (m_bIsRetinaEnabled)
{ {
pTouch->setTouchInfo(nUnusedIndex, (x - m_rcViewPort.origin.x) / m_fScreenScaleFactor, // on iOS, though retina is enabled, the value got from os is also
(y - m_rcViewPort.origin.y) / m_fScreenScaleFactor); // relative to its original size
pTouch->setTouchInfo(nUnusedIndex, (x - m_obViewPortRect.origin.x),
(y - m_obViewPortRect.origin.y));
} }
else else
{ {
pTouch->setTouchInfo(nUnusedIndex, x, y); pTouch->setTouchInfo(nUnusedIndex, (x - m_obViewPortRect.origin.x) / m_fXScale,
(y - m_obViewPortRect.origin.y) / m_fYScale);
} }
CCLOG("x = %f y = %f", pTouch->getLocationInView().x, pTouch->getLocationInView().y);
CCInteger* pInterObj = new CCInteger(nUnusedIndex); CCInteger* pInterObj = new CCInteger(nUnusedIndex);
s_TouchesIntergerDict.setObject(pInterObj, id); s_TouchesIntergerDict.setObject(pInterObj, id);
set.addObject(pTouch); set.addObject(pTouch);
@ -256,15 +243,17 @@ void CCEGLViewProtocol::handleTouchesMove(int num, int ids[], float xs[], float
CCTouch* pTouch = s_pTouches[pIndex->getValue()]; CCTouch* pTouch = s_pTouches[pIndex->getValue()];
if (pTouch) if (pTouch)
{ {
if (m_bNeedScale) if (m_bIsRetinaEnabled)
{ {
pTouch->setTouchInfo(pIndex->getValue(), (x - m_rcViewPort.origin.x) / m_fScreenScaleFactor, pTouch->setTouchInfo(pIndex->getValue(), (x - m_obViewPortRect.origin.x),
(y - m_rcViewPort.origin.y) / m_fScreenScaleFactor); (y - m_obViewPortRect.origin.y));
} }
else else
{ {
pTouch->setTouchInfo(pIndex->getValue(), x, y); pTouch->setTouchInfo(pIndex->getValue(), (x - m_obViewPortRect.origin.x) / m_fXScale,
(y - m_obViewPortRect.origin.y) / m_fYScale);
} }
set.addObject(pTouch); set.addObject(pTouch);
} }
else else
@ -303,17 +292,18 @@ void CCEGLViewProtocol::getSetOfTouchesEndOrCancel(CCSet& set, int num, int ids[
if (pTouch) if (pTouch)
{ {
CCLOGINFO("Ending touches with id: %d, x=%f, y=%f", id, x, y); CCLOGINFO("Ending touches with id: %d, x=%f, y=%f", id, x, y);
if (m_bNeedScale)
{
pTouch->setTouchInfo(pIndex->getValue(), (x - m_rcViewPort.origin.x) / m_fScreenScaleFactor,
(y - m_rcViewPort.origin.y) / m_fScreenScaleFactor);
}
else
{
pTouch->setTouchInfo(pIndex->getValue(), x, y);
}
if (m_bIsRetinaEnabled)
{
pTouch->setTouchInfo(pIndex->getValue(), (x - m_obViewPortRect.origin.x),
(y - m_obViewPortRect.origin.y));
}
else
{
pTouch->setTouchInfo(pIndex->getValue(), (x - m_obViewPortRect.origin.x) / m_fXScale,
(y - m_obViewPortRect.origin.y) / m_fYScale);
}
set.addObject(pTouch); set.addObject(pTouch);
// release the object // release the object

View File

@ -3,6 +3,21 @@
#include "ccTypes.h" #include "ccTypes.h"
enum ResolutionPolicy
{
// 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,
};
NS_CC_BEGIN NS_CC_BEGIN
#define CC_MAX_TOUCHES 5 #define CC_MAX_TOUCHES 5
@ -26,20 +41,17 @@ public:
virtual void swapBuffers() = 0; virtual void swapBuffers() = 0;
virtual void setIMEKeyboardState(bool bOpen) = 0; virtual void setIMEKeyboardState(bool bOpen) = 0;
virtual CCRect getViewPort();
virtual CCSize getSize(); virtual CCSize getSize();
virtual void setFrameSize(float width, float height); virtual void setSize(float width, float height);
virtual CCSize getFrameSize(); virtual CCSize getVisibleSize();
virtual void setDesignResolutionSize(float width, float height); virtual CCPoint getVisibleOrigin();
virtual void setDesignResolutionSize(float width, float height, ResolutionPolicy resolutionPolicy);
virtual void setTouchDelegate(EGLTouchDelegate * pDelegate); virtual void setTouchDelegate(EGLTouchDelegate * pDelegate);
virtual float getScreenScaleFactor(); virtual float getScreenScaleFactor();
virtual bool canSetContentScaleFactor(); virtual bool setContentScaleFactor(float contentScaleFactor);
virtual void setContentScaleFactor(float contentScaleFactor);
virtual void setViewPortInPoints(float x , float y , float w , float h); virtual void setViewPortInPoints(float x , float y , float w , float h);
virtual void setScissorInPoints(float x , float y , float w , float h); virtual void setScissorInPoints(float x , float y , float w , float h);
virtual float getMainScreenScale(); virtual bool enableRetina();
virtual void setViewName(const char* pszViewName);
const char* getViewName();
/** handle touch events by default, if you want to custom your handles, please override these functions */ /** handle touch events by default, if you want to custom your handles, please override these functions */
virtual void handleTouchesBegin(int num, int ids[], float xs[], float ys[]); virtual void handleTouchesBegin(int num, int ids[], float xs[], float ys[]);
@ -50,13 +62,19 @@ public:
private: private:
void getSetOfTouchesEndOrCancel(CCSet& set, int num, int ids[], float xs[], float ys[]); void getSetOfTouchesEndOrCancel(CCSet& set, int num, int ids[], float xs[], float ys[]);
protected: protected:
bool m_bNeedScale;
EGLTouchDelegate* m_pDelegate; EGLTouchDelegate* m_pDelegate;
float m_fScreenScaleFactor; float m_fScreenScaleFactor;
CCSize m_sSizeInPixel; // real size of screen
CCSize m_sSizeInPoint; CCSize m_obScreenSize;
CCRect m_rcViewPort; // resolution size, it is the size the app resources designed for
char m_szViewName[50]; CCSize m_obDesignResolutionSize;
// the view port size
CCRect m_obViewPortRect;
char m_szViewName[50];
float m_fXScale;
float m_fYScale;
ResolutionPolicy m_eResolutionPolicy;
bool m_bIsRetinaEnabled;
}; };
// end of platform group // end of platform group

View File

@ -62,16 +62,6 @@ public:
*/ */
unsigned char* getFileDataFromZip(const char* pszZipFilePath, const char* pszFileName, unsigned long * pSize); unsigned char* getFileDataFromZip(const char* pszZipFilePath, const char* pszFileName, unsigned long * pSize);
/** removes the suffix from a path
* On RetinaDisplay it will remove the -hd suffix
* On iPad it will remove the -ipad suffix
* On iPhone it will remove the (empty) suffix
Only valid on iOS. Not valid for OS X.
@since v0.99.5
*/
std::string& removeSuffixFromFile(std::string& path);
/** /**
@brief Generate the absolute path of the file. @brief Generate the absolute path of the file.
@param pszRelativePath The relative path of the file. @param pszRelativePath The relative path of the file.
@ -82,76 +72,15 @@ public:
*/ */
const char* fullPathFromRelativePath(const char *pszRelativePath); const char* fullPathFromRelativePath(const char *pszRelativePath);
/** Returns the fullpath of an filename including the resolution of the image.
If in RetinaDisplay mode, and a RetinaDisplay file is found, it will return that path.
If in iPad mode, and an iPad file is found, it will return that path.
Examples:
* In iPad mode: "image.png" -> "/full/path/image-ipad.png" (in case the -ipad file exists)
* In RetinaDisplay mode: "image.png" -> "/full/path/image-hd.png" (in case the -hd file exists)
If an iPad file is found, it will set resolution type to kCCResolutioniPad
If a RetinaDisplay file is found, it will set resolution type to kCCResolutionRetinaDisplay
*/
const char* fullPathFromRelativePath(const char *pszRelativePath, ccResolutionType *pResolutionType);
/// @cond /// @cond
const char* fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile); const char* fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile);
/// @endcond /// @endcond
/** Sets the iPhone RetinaDisplay suffix to load resources.
By default it is "-hd".
Only valid on iOS. Not valid for OS X.
@since v1.1
*/
void setiPhoneRetinaDisplaySuffix(const char *suffix);
/** Sets the iPad suffix to load resources.
By default it is "".
Only valid on iOS. Not valid for OS X.
*/
void setiPadSuffix(const char *suffix);
/** Sets the iPad Retina Display suffix to load resources.
By default it is "-ipadhd".
Only valid on iOS. Not valid for OS X.
@since v1.1
*/
void setiPadRetinaDisplaySuffix(const char *suffix);
/** Returns whether or not a given filename exists with the iPad suffix.
Only available on iOS. Not supported on OS X.
@since v1.1
*/
bool iPadFileExistsAtPath(const char *filename);
/** Returns whether or not a given filename exists with the iPad RetinaDisplay suffix.
Only available on iOS. Not supported on OS X.
@since v2.0
*/
bool iPadRetinaDisplayFileExistsAtPath(const char *filename);
/** Returns whether or not a given path exists with the iPhone RetinaDisplay suffix.
Only available on iOS. Not supported on OS X.
@since v1.1
*/
bool iPhoneRetinaDisplayFileExistsAtPath(const char *filename);
/** /**
@brief Set the ResourcePath,we will find resource in this path @brief Set the ResourcePath,we will find resource relative to this path
@param pszResourcePath The absolute resource path @param pszResourcePath Relative path to root
@warning Don't call this function in android and iOS, it has not effect.
In android, if you want to read file other than apk, you shoud use invoke getFileData(), and pass the
absolute path.
*/ */
void setResourcePath(const char *pszResourcePath); void setResourceDirectory(const char *pszDirectoryName);
/** /**
@brief Get the writeable path @brief Get the writeable path
@ -164,6 +93,9 @@ public:
*/ */
void setPopupNotify(bool bNotify); void setPopupNotify(bool bNotify);
bool isPopupNotify(); bool isPopupNotify();
protected:
std::string m_obDirectory;
}; };
// end of platform group // end of platform group

View File

@ -42,10 +42,6 @@ THE SOFTWARE.
NS_CC_BEGIN NS_CC_BEGIN
static const char *__suffixiPhoneRetinaDisplay = "-hd";
static const char *__suffixiPad = "-ipad";
static const char *__suffixiPadRetinaDisplay = "-ipadhd";
typedef enum typedef enum
{ {
SAX_NONE = 0, SAX_NONE = 0,
@ -322,27 +318,6 @@ public:
} }
}; };
std::string& CCFileUtils::removeSuffixFromFile(std::string& path)
{
// XXX win32 now can only support iphone retina, because
// we don't know it is ipad retina or iphone retina.
// fixe me later
if( CC_CONTENT_SCALE_FACTOR() == 2 )
{
std::string::size_type pos = path.rfind("/") + 1; // the begin index of last part of path
std::string::size_type suffixPos = path.rfind(__suffixiPhoneRetinaDisplay);
if (std::string::npos != suffixPos && suffixPos > pos)
{
CCLog("cocos2d: FilePath(%s) contains suffix(%s), remove it.", path.c_str(),
__suffixiPhoneRetinaDisplay);
path.replace(suffixPos, strlen(__suffixiPhoneRetinaDisplay), "");
}
}
return path;
}
CCDictionary* ccFileUtils_dictionaryWithContentsOfFileThreadSafe(const char *pFileName) CCDictionary* ccFileUtils_dictionaryWithContentsOfFileThreadSafe(const char *pFileName)
{ {
CCDictMaker tMaker; CCDictMaker tMaker;
@ -397,45 +372,13 @@ unsigned char* CCFileUtils::getFileDataFromZip(const char* pszZipFilePath, const
return pBuffer; return pBuffer;
} }
void CCFileUtils::setResourceDirectory(const char* pszResourceDirectory)
const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
{ {
ccResolutionType ignore; m_obDirectory = pszResourceDirectory;
return fullPathFromRelativePath(pszRelativePath, &ignore); if (m_obDirectory.size() > 0 && m_obDirectory[m_obDirectory.size() - 1] != '/')
} {
m_obDirectory.append("/");
/// functions iOS specific }
void CCFileUtils::setiPhoneRetinaDisplaySuffix(const char *suffix)
{
CCAssert(0, "not implement");
}
void CCFileUtils::setiPadSuffix(const char *suffix)
{
CCAssert(0, "not implement");
}
void CCFileUtils::setiPadRetinaDisplaySuffix(const char *suffix)
{
CCAssert(0, "not implement");
}
bool CCFileUtils::iPadFileExistsAtPath(const char *filename)
{
CCAssert(0, "not implement");
return false;
}
bool CCFileUtils::iPadRetinaDisplayFileExistsAtPath(const char *filename)
{
CCAssert(0, "not implement");
return false;
}
bool CCFileUtils::iPhoneRetinaDisplayFileExistsAtPath(const char *filename)
{
CCAssert(0, "not implement");
return false;
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

View File

@ -64,7 +64,7 @@ CCEGLView::~CCEGLView()
bool CCEGLView::isOpenGLReady() bool CCEGLView::isOpenGLReady()
{ {
return (m_sSizeInPixel.width != 0 && m_sSizeInPixel.height != 0); return (m_obScreenSize.width != 0 && m_obScreenSize.height != 0);
} }
void CCEGLView::end() void CCEGLView::end()

View File

@ -31,6 +31,7 @@ NS_CC_BEGIN
#include "platform/CCCommon.h" #include "platform/CCCommon.h"
#include "jni/SystemInfoJni.h" #include "jni/SystemInfoJni.h"
#include "jni/MessageJni.h"
// record the resource path // record the resource path
static string s_strResourcePath = ""; static string s_strResourcePath = "";
@ -42,6 +43,7 @@ CCFileUtils* CCFileUtils::sharedFileUtils()
if (s_pFileUtils == NULL) if (s_pFileUtils == NULL)
{ {
s_pFileUtils = new CCFileUtils(); s_pFileUtils = new CCFileUtils();
s_strResourcePath = getApkPath();
} }
return s_pFileUtils; return s_pFileUtils;
} }
@ -61,25 +63,7 @@ void CCFileUtils::purgeCachedEntries()
} }
/* const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
* This function is implemented for jni to set apk path.
*/
void CCFileUtils::setResourcePath(const char* pszResourcePath)
{
CCAssert(pszResourcePath != NULL, "[FileUtils setRelativePath] -- wrong relative path");
string tmp(pszResourcePath);
if ((! pszResourcePath) || tmp.find(".apk") == string::npos)
{
return;
}
s_strResourcePath = pszResourcePath;
}
const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath,
ccResolutionType *pResolutionType)
{ {
return pszRelativePath; return pszRelativePath;
} }
@ -107,8 +91,18 @@ unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* psz
if (pszFileName[0] != '/') if (pszFileName[0] != '/')
{ {
// read from apk // read from apk
string pathWithoutDirectory = fullPath;
fullPath.insert(0, m_obDirectory.c_str());
fullPath.insert(0, "assets/"); fullPath.insert(0, "assets/");
pData = CCFileUtils::getFileDataFromZip(s_strResourcePath.c_str(), fullPath.c_str(), pSize); pData = CCFileUtils::getFileDataFromZip(s_strResourcePath.c_str(), fullPath.c_str(), pSize);
if (! pData && m_obDirectory.size() > 0)
{
// search from root
pathWithoutDirectory.insert(0, "assets/");
pData = CCFileUtils::getFileDataFromZip(s_strResourcePath.c_str(), pathWithoutDirectory.c_str(), pSize);
}
} }
else else
{ {

View File

@ -44,6 +44,8 @@ using namespace cocos2d;
extern "C" extern "C"
{ {
char *g_pApkPath;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// native renderer // native renderer
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -127,8 +129,13 @@ extern "C"
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void Java_org_cocos2dx_lib_Cocos2dxActivity_nativeSetPaths(JNIEnv* env, jobject thiz, jstring apkPath) void Java_org_cocos2dx_lib_Cocos2dxActivity_nativeSetPaths(JNIEnv* env, jobject thiz, jstring apkPath)
{ {
const char* str = env->GetStringUTFChars(apkPath, NULL); g_pApkPath = (char*)env->GetStringUTFChars(apkPath, NULL);
cocos2d::CCFileUtils::sharedFileUtils()->setResourcePath(str); // don't release it, we will use it later
env->ReleaseStringUTFChars(apkPath, str); //env->ReleaseStringUTFChars(apkPath, str);
}
char* getApkPath()
{
return g_pApkPath;
} }
} }

View File

@ -29,6 +29,7 @@ extern "C"
{ {
extern void showMessageBoxJNI(const char * pszMsg, const char * pszTitle); extern void showMessageBoxJNI(const char * pszMsg, const char * pszTitle);
extern void terminateProcessJNI(); extern void terminateProcessJNI();
extern char* getApkPath();
} }
#endif // __ANDROID_MESSAGE_JNI_H__ #endif // __ANDROID_MESSAGE_JNI_H__

View File

@ -49,12 +49,6 @@ extern "C"
void Java_org_cocos2dx_lib_Cocos2dxAccelerometer_onSensorChanged(JNIEnv* env, jobject thiz, jfloat x, jfloat y, jfloat z, jlong timeStamp) void Java_org_cocos2dx_lib_Cocos2dxAccelerometer_onSensorChanged(JNIEnv* env, jobject thiz, jfloat x, jfloat y, jfloat z, jlong timeStamp)
{ {
// We need to invert to make it compatible with iOS. // We need to invert to make it compatible with iOS.
CCRect rcRect = CCEGLView::sharedOpenGLView().getViewPort();
float fScreenScaleFactor = CCEGLView::sharedOpenGLView().getScreenScaleFactor();
// cocos2d::CCAccelerometer::sharedAccelerometer()->update((x - rcRect.origin.x) / fScreenScaleFactor,
// (y - rcRect.origin.y) / fScreenScaleFactor,
// z,
// timeStamp);
CCDirector* pDirector = CCDirector::sharedDirector(); CCDirector* pDirector = CCDirector::sharedDirector();
pDirector->getAccelerometer()->update(x, y, z, timeStamp); pDirector->getAccelerometer()->update(x, y, z, timeStamp);
} }

View File

@ -81,6 +81,7 @@ public:
virtual ccLanguageType getCurrentLanguage(); virtual ccLanguageType getCurrentLanguage();
virtual bool isIpad(); virtual bool isIpad();
virtual bool isIos();
protected: protected:
static CCApplication * sm_pSharedApplication; static CCApplication * sm_pSharedApplication;

View File

@ -155,4 +155,9 @@ bool CCApplication::isIpad()
return false; return false;
} }
bool CCApplication::isIos()
{
return true;
}
NS_CC_END NS_CC_END

View File

@ -38,21 +38,17 @@ public:
CCEGLView(); CCEGLView();
~CCEGLView(); ~CCEGLView();
CCSize getSize(); virtual bool isOpenGLReady();
bool isOpenGLReady(); virtual bool isIpad();
bool canSetContentScaleFactor(); virtual bool setContentScaleFactor(float contentScaleFactor);
bool isIpad();
void setContentScaleFactor(float contentScaleFactor);
virtual CCSize getFrameSize(); virtual CCSize getFrameSize();
virtual bool enableRetina();
// keep compatible // keep compatible
void end(); virtual void end();
void swapBuffers(); virtual void swapBuffers();
float getMainScreenScale(); virtual void setIMEKeyboardState(bool bOpen);
void setIMEKeyboardState(bool bOpen);
static CCEGLView& sharedOpenGLView(); static CCEGLView& sharedOpenGLView();

View File

@ -32,7 +32,8 @@ NS_CC_BEGIN
CCEGLView::CCEGLView() CCEGLView::CCEGLView()
{ {
m_obScreenSize.width = m_obDesignResolutionSize.width = [[EAGLView sharedEGLView] getWidth];
m_obScreenSize.height = m_obDesignResolutionSize.height = [[EAGLView sharedEGLView] getHeight];
} }
CCEGLView::~CCEGLView() CCEGLView::~CCEGLView()
@ -40,13 +41,6 @@ CCEGLView::~CCEGLView()
} }
CCSize CCEGLView::getSize()
{
cocos2d::CCSize size([[EAGLView sharedEGLView] getWidth], [[EAGLView sharedEGLView] getHeight]);
return size;
}
bool CCEGLView::isIpad() bool CCEGLView::isIpad()
{ {
return UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad; return UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad;
@ -57,16 +51,38 @@ bool CCEGLView::isOpenGLReady()
return [EAGLView sharedEGLView] != NULL; return [EAGLView sharedEGLView] != NULL;
} }
bool CCEGLView::canSetContentScaleFactor() bool CCEGLView::setContentScaleFactor(float contentScaleFactor)
{ {
return [[EAGLView sharedEGLView] respondsToSelector:@selector(setContentScaleFactor:)]; // can not enable retina because have used resolution policy
} assert(m_eResolutionPolicy == kResolutionUnKnown);
void CCEGLView::setContentScaleFactor(float contentScaleFactor) if ([[EAGLView sharedEGLView] respondsToSelector:@selector(setContentScaleFactor:)])
{
UIView * view = [EAGLView sharedEGLView];
view.contentScaleFactor = contentScaleFactor;
[view setNeedsLayout];
m_fXScale = m_fYScale = contentScaleFactor;
m_bIsRetinaEnabled = true;
return true;
}
else
{
return false;
}
}
bool CCEGLView::enableRetina()
{ {
UIView * view = [EAGLView sharedEGLView]; bool ret = true;
view.contentScaleFactor = contentScaleFactor;
[view setNeedsLayout]; // can set content scale factor?
ret &= [[EAGLView sharedEGLView] respondsToSelector:@selector(setContentScaleFactor:)];
// SD device?
ret &= ([[UIScreen mainScreen] scale] != 1.0f);
return ret;
} }
void CCEGLView::end() void CCEGLView::end()
@ -107,10 +123,5 @@ CCEGLView& CCEGLView::sharedOpenGLView()
return instance; return instance;
} }
float CCEGLView::getMainScreenScale()
{
return [[UIScreen mainScreen] scale];
}
NS_CC_END NS_CC_END

View File

@ -44,9 +44,7 @@ USING_NS_CC;
static void static_addValueToCCDict(id key, id value, CCDictionary* pDict); static void static_addValueToCCDict(id key, id value, CCDictionary* pDict);
static void static_addItemToCCArray(id item, CCArray* pArray); static void static_addItemToCCArray(id item, CCArray* pArray);
static NSString *__suffixiPhoneRetinaDisplay =@"-hd";
static NSString *__suffixiPad =@"-ipad";
static NSString *__suffixiPadRetinaDisplay =@"-ipadhd";
static NSFileManager *__localFileManager= [[NSFileManager alloc] init]; static NSFileManager *__localFileManager= [[NSFileManager alloc] init];
static NSString* removeSuffixFromPath(NSString *suffix, NSString *path) static NSString* removeSuffixFromPath(NSString *suffix, NSString *path)
@ -238,60 +236,9 @@ void CCFileUtils::purgeCachedEntries()
} }
void CCFileUtils::setResourcePath(const char *pszResourcePath) void CCFileUtils::setResourceDirectory(const char *pszDirectoryName)
{ {
assert(0); m_obDirectory = pszDirectoryName;
}
std::string& CCFileUtils::removeSuffixFromFile(std::string& cpath )
{
NSString *ret = nil;
NSString *path = [NSString stringWithUTF8String:cpath.c_str()];
if( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad )
{
if( CC_CONTENT_SCALE_FACTOR() == 2 )
{
ret = removeSuffixFromPath(__suffixiPadRetinaDisplay, path);
}
else
{
ret = removeSuffixFromPath(__suffixiPad, path);
}
}
else
{
if( CC_CONTENT_SCALE_FACTOR() == 2 )
{
ret = removeSuffixFromPath(__suffixiPhoneRetinaDisplay, [NSString stringWithUTF8String:cpath.c_str()]);
}
else
{
ret = path;
}
}
cpath = [ret UTF8String];
return cpath;
}
void CCFileUtils::setiPhoneRetinaDisplaySuffix(const char *suffix)
{
[__suffixiPhoneRetinaDisplay release];
__suffixiPhoneRetinaDisplay = [[NSString stringWithUTF8String:suffix] retain];
}
void CCFileUtils::setiPadSuffix(const char *suffix)
{
[__suffixiPad release];
__suffixiPad = [[NSString stringWithUTF8String:suffix] retain];
}
void CCFileUtils::setiPadRetinaDisplaySuffix(const char *suffix)
{
[__suffixiPadRetinaDisplay release];
__suffixiPadRetinaDisplay = [[NSString stringWithUTF8String:suffix] retain];
} }
bool fileExistsAtPath(const char *cpath, const char *csuffix) bool fileExistsAtPath(const char *cpath, const char *csuffix)
@ -320,87 +267,42 @@ bool fileExistsAtPath(const char *cpath, const char *csuffix)
return ( path != nil ); return ( path != nil );
} }
bool CCFileUtils::iPhoneRetinaDisplayFileExistsAtPath(const char *cpath)
{
return fileExistsAtPath(cpath, [__suffixiPhoneRetinaDisplay UTF8String]);
}
bool CCFileUtils::iPadFileExistsAtPath(const char *cpath)
{
return fileExistsAtPath(cpath, [__suffixiPad UTF8String]);
}
bool CCFileUtils::iPadRetinaDisplayFileExistsAtPath(const char *cpath)
{
return fileExistsAtPath(cpath, [__suffixiPadRetinaDisplay UTF8String]);
}
const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath) const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
{
ccResolutionType ignore;
return fullPathFromRelativePath(pszRelativePath, &ignore);
}
const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath, ccResolutionType *pResolutionType)
{ {
CCAssert(pszRelativePath != NULL, "CCFileUtils: Invalid path"); CCAssert(pszRelativePath != NULL, "CCFileUtils: Invalid path");
NSString *fullpath = nil; NSString *fullpath = nil;
NSString *relPath = [NSString stringWithUTF8String:pszRelativePath]; NSString *relPath = [NSString stringWithUTF8String:pszRelativePath];
// only if it is not an absolute path // only if it is not an absolute path
if( ! [relPath isAbsolutePath] ) { if( ! [relPath isAbsolutePath] ) {
// pathForResource also searches in .lproj directories. issue #1230 // pathForResource also searches in .lproj directories. issue #1230
NSString *file = [relPath lastPathComponent]; NSString *file = [relPath lastPathComponent];
NSString *imageDirectory = [relPath stringByDeletingLastPathComponent];
NSMutableString *imageDirectory = [NSMutableString stringWithUTF8String:m_obDirectory.c_str()];
NSMutableString *imageDirectoryWithDirectory = imageDirectory;
[imageDirectoryWithDirectory appendString:[relPath stringByDeletingLastPathComponent]];
// search path from directory set by setResourceDirectory
fullpath = [[NSBundle mainBundle] pathForResource:file fullpath = [[NSBundle mainBundle] pathForResource:file
ofType:nil ofType:nil
inDirectory:imageDirectory]; inDirectory:imageDirectoryWithDirectory];
if (fullpath == nil)
{
// search from root directory
fullpath = [[NSBundle mainBundle] pathForResource:file
ofType:nil
inDirectory:imageDirectory];
}
} }
if (fullpath == nil) if (fullpath == nil)
{ {
fullpath = relPath; fullpath = relPath;
} }
NSString *ret = nil; return [fullpath UTF8String];
// iPad?
if( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
// Retina Display ?
if( CC_CONTENT_SCALE_FACTOR() == 2 ) {
ret = getPathForSuffix(fullpath, __suffixiPadRetinaDisplay);
*pResolutionType = kCCResolutioniPadRetinaDisplay;
}
else
{
ret = getPathForSuffix(fullpath, __suffixiPad);
*pResolutionType = kCCResolutioniPad;
}
}
// iPhone ?
else
{
// Retina Display ?
if( CC_CONTENT_SCALE_FACTOR() == 2 ) {
ret = getPathForSuffix(fullpath, __suffixiPhoneRetinaDisplay);
*pResolutionType = kCCResolutioniPhoneRetinaDisplay;
}
}
// If it is iPhone Non RetinaDisplay, or if the previous "getPath" failed, then use iPhone images.
if( ret == nil )
{
*pResolutionType = kCCResolutioniPhone;
ret = fullpath;
}
return [ret UTF8String];
} }
const char *CCFileUtils::fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile) const char *CCFileUtils::fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile)

View File

@ -397,7 +397,7 @@ void CCEGLView::resize(int width, int height)
rcClient.bottom - rcClient.top, SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER); rcClient.bottom - rcClient.top, SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER);
} }
void CCEGLView::setFrameSize(float width, float height) void CCEGLView::setSize(float width, float height)
{ {
Create((LPCTSTR)m_szViewName, (int)width, (int)height); Create((LPCTSTR)m_szViewName, (int)width, (int)height);
CCEGLViewProtocol::setFrameSize(width, height); CCEGLViewProtocol::setFrameSize(width, height);
@ -435,16 +435,13 @@ void CCEGLView::centerWindow()
SetWindowPos(m_hWnd, 0, offsetX, offsetY, 0, 0, SWP_NOCOPYBITS | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOZORDER); SetWindowPos(m_hWnd, 0, offsetX, offsetY, 0, 0, SWP_NOCOPYBITS | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOZORDER);
} }
bool CCEGLView::canSetContentScaleFactor() bool CCEGLView::setContentScaleFactor(float contentScaleFactor)
{
return true;
}
void CCEGLView::setContentScaleFactor(float contentScaleFactor)
{ {
CCEGLViewProtocol::setContentScaleFactor(contentScaleFactor); CCEGLViewProtocol::setContentScaleFactor(contentScaleFactor);
resize((int)(m_sSizeInPixel.width * contentScaleFactor), (int)(m_sSizeInPixel.height * contentScaleFactor)); resize((int)(m_sSizeInPixel.width * contentScaleFactor), (int)(m_sSizeInPixel.height * contentScaleFactor));
centerWindow(); centerWindow();
return true
} }
CCEGLView& CCEGLView::sharedOpenGLView() CCEGLView& CCEGLView::sharedOpenGLView()

View File

@ -44,9 +44,8 @@ public:
virtual bool isOpenGLReady(); virtual bool isOpenGLReady();
virtual void end(); virtual void end();
virtual void swapBuffers(); virtual void swapBuffers();
virtual bool canSetContentScaleFactor(); virtual bool setContentScaleFactor(float contentScaleFactor);
virtual void setContentScaleFactor(float contentScaleFactor); virtual void setSize(float width, float height);
virtual void setFrameSize(float width, float height);
virtual void setIMEKeyboardState(bool bOpen); virtual void setIMEKeyboardState(bool bOpen);
private: private:

View File

@ -83,7 +83,7 @@ void CCFileUtils::setResourcePath(const char *pszResourcePath)
strcpy(s_pszResourcePath, pszResourcePath); strcpy(s_pszResourcePath, pszResourcePath);
} }
const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath, ccResolutionType *pResolutionType) const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
{ {
_CheckPath(); _CheckPath();

View File

@ -235,7 +235,6 @@ bool CCTexture2D::initWithData(const void *data, CCTexture2DPixelFormat pixelFor
m_bHasPremultipliedAlpha = false; m_bHasPremultipliedAlpha = false;
m_bHasMipmaps = false; m_bHasMipmaps = false;
m_eResolutionType = kCCResolutionUnknown;
setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTexture)); setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTexture));
return true; return true;
@ -250,11 +249,6 @@ const char* CCTexture2D::description(void)
// implementation CCTexture2D (Image) // implementation CCTexture2D (Image)
bool CCTexture2D::initWithImage(CCImage *uiImage) bool CCTexture2D::initWithImage(CCImage *uiImage)
{
return initWithImage(uiImage, kCCResolutionUnknown);
}
bool CCTexture2D::initWithImage(CCImage * uiImage, ccResolutionType resolution)
{ {
if (uiImage == NULL) if (uiImage == NULL)
{ {
@ -267,7 +261,7 @@ bool CCTexture2D::initWithImage(CCImage * uiImage, ccResolutionType resolution)
unsigned int imageHeight = uiImage->getHeight(); unsigned int imageHeight = uiImage->getHeight();
CCConfiguration *conf = CCConfiguration::sharedConfiguration(); CCConfiguration *conf = CCConfiguration::sharedConfiguration();
unsigned maxTextureSize = conf->getMaxTextureSize(); unsigned maxTextureSize = conf->getMaxTextureSize();
if (imageWidth > maxTextureSize || imageHeight > maxTextureSize) if (imageWidth > maxTextureSize || imageHeight > maxTextureSize)
{ {
@ -275,12 +269,11 @@ bool CCTexture2D::initWithImage(CCImage * uiImage, ccResolutionType resolution)
this->release(); this->release();
return NULL; return NULL;
} }
m_eResolutionType = resolution;
// always load premultiplied images // always load premultiplied images
return initPremultipliedATextureWithImage(uiImage, imageWidth, imageHeight); return initPremultipliedATextureWithImage(uiImage, imageWidth, imageHeight);
} }
bool CCTexture2D::initPremultipliedATextureWithImage(CCImage *image, unsigned int width, unsigned int height) bool CCTexture2D::initPremultipliedATextureWithImage(CCImage *image, unsigned int width, unsigned int height)
{ {
unsigned char* tempData = image->getData(); unsigned char* tempData = image->getData();

View File

@ -134,8 +134,6 @@ public:
bool initWithImage(CCImage * uiImage); bool initWithImage(CCImage * uiImage);
bool initWithImage(CCImage *uiImage, ccResolutionType resolution);
/** Initializes a texture from a string with dimensions, alignment, font name and font size */ /** Initializes a texture from a string with dimensions, alignment, font name and font size */
bool initWithString(const char *text, const CCSize& dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize); bool initWithString(const char *text, const CCSize& dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize);
/** Initializes a texture from a string with font name and font size */ /** Initializes a texture from a string with font name and font size */
@ -273,17 +271,6 @@ private:
/** shader program used by drawAtPoint and drawInRect */ /** shader program used by drawAtPoint and drawInRect */
CC_PROPERTY(CCGLProgram*, m_pShaderProgram, ShaderProgram); CC_PROPERTY(CCGLProgram*, m_pShaderProgram, ShaderProgram);
/** Returns the resolution type of the texture.
Is it a RetinaDisplay texture, an iPad texture or an standard texture ?
Only valid on iOS. Not valid on OS X.
Should be a readonly property. It is readwrite as a hack.
@since v1.1
*/
CC_SYNTHESIZE(ccResolutionType, m_eResolutionType, ResolutionType);
}; };
// end of textures group // end of textures group

View File

@ -257,7 +257,6 @@ void CCTextureCache::addImageAsync(const char *path, CCObject *target, SEL_CallF
// optimization // optimization
std::string pathKey = path; std::string pathKey = path;
CCFileUtils::sharedFileUtils()->removeSuffixFromFile(pathKey);
pathKey = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pathKey.c_str()); pathKey = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pathKey.c_str());
texture = (CCTexture2D*)m_pTextures->objectForKey(pathKey.c_str()); texture = (CCTexture2D*)m_pTextures->objectForKey(pathKey.c_str());
@ -400,8 +399,6 @@ CCTexture2D * CCTextureCache::addImage(const char * path)
// remove possible -HD suffix to prevent caching the same image twice (issue #1040) // remove possible -HD suffix to prevent caching the same image twice (issue #1040)
std::string pathKey = path; std::string pathKey = path;
ccResolutionType resolution = kCCResolutionUnknown;
CCFileUtils::sharedFileUtils()->removeSuffixFromFile(pathKey);
pathKey = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pathKey.c_str()); pathKey = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pathKey.c_str());
texture = (CCTexture2D*)m_pTextures->objectForKey(pathKey.c_str()); texture = (CCTexture2D*)m_pTextures->objectForKey(pathKey.c_str());
@ -446,7 +443,7 @@ CCTexture2D * CCTextureCache::addImage(const char * path)
texture = new CCTexture2D(); texture = new CCTexture2D();
if( texture && if( texture &&
texture->initWithImage(&image, resolution) ) texture->initWithImage(&image) )
{ {
#if CC_ENABLE_CACHE_TEXTURE_DATA #if CC_ENABLE_CACHE_TEXTURE_DATA
// cache the texture file name // cache the texture file name
@ -477,7 +474,6 @@ CCTexture2D* CCTextureCache::addPVRTCImage(const char* path, int bpp, bool hasAl
CCTexture2D * texture; CCTexture2D * texture;
std::string temp(path); std::string temp(path);
CCFileUtils::sharedFileUtils()->removeSuffixFromFile(temp);
if ( (texture = (CCTexture2D*)m_pTextures->objectForKey(temp.c_str())) ) if ( (texture = (CCTexture2D*)m_pTextures->objectForKey(temp.c_str())) )
{ {
@ -514,8 +510,6 @@ CCTexture2D * CCTextureCache::addPVRImage(const char* path)
CCTexture2D* texture = NULL; CCTexture2D* texture = NULL;
std::string key(path); std::string key(path);
// remove possible -HD suffix to prevent caching the same image twice (issue #1040)
CCFileUtils::sharedFileUtils()->removeSuffixFromFile(key);
if( (texture = (CCTexture2D*)m_pTextures->objectForKey(key.c_str())) ) if( (texture = (CCTexture2D*)m_pTextures->objectForKey(key.c_str())) )
{ {
@ -568,7 +562,7 @@ CCTexture2D* CCTextureCache::addUIImage(CCImage *image, const char *key)
// prevents overloading the autorelease pool // prevents overloading the autorelease pool
texture = new CCTexture2D(); texture = new CCTexture2D();
texture->initWithImage(image, kCCResolutionUnknown); texture->initWithImage(image);
if(key && texture) if(key && texture)
{ {
@ -890,8 +884,7 @@ void VolatileTexture::reloadAllTextures()
break; break;
case kImage: case kImage:
{ {
vt->texture->initWithImage(vt->uiImage, vt->texture->initWithImage(vt->uiImage);
kCCResolutionUnknown);
} }
break; break;
default: default:

View File

@ -16,9 +16,41 @@ bool AppDelegate::applicationDidFinishLaunching() {
CCDirector *pDirector = CCDirector::sharedDirector(); CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView()); pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView());
// enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices. if (isIpad())
// pDirector->enableRetinaDisplay(true); {
// ipad
CCFileUtils::sharedFileUtils()->setResourceDirectory("iphonehd");
// don't enable retina because we don't have ipad hd resource
CCEGLView::sharedOpenGLView().setDesignResolutionSize(960, 640, kCCResolutionNoBorder);
}
else
{
// iphone or other platforms
if (pDirector->enableRetinaDisplay(true))
{
// iphone hd
CCFileUtils::sharedFileUtils()->setResourceDirectory("iphonehd");
}
else
{
if (isIos())
{
// iphone
CCFileUtils::sharedFileUtils()->setResourceDirectory("iphone");
}
else
{
// android or other platform, use hd resource
CCFileUtils::sharedFileUtils()->setResourceDirectory("iphonehd");
CCEGLView::sharedOpenGLView().setDesignResolutionSize(960, 640, kCCResolutionNoBorder);
}
}
}
// turn on display FPS // turn on display FPS
pDirector->setDisplayStats(true); pDirector->setDisplayStats(true);

View File

@ -26,6 +26,9 @@ bool HelloWorld::init()
{ {
return false; return false;
} }
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 // 2. add a menu item with "X" image, which is clicked to quit the program
@ -36,12 +39,19 @@ bool HelloWorld::init()
"CloseNormal.png", "CloseNormal.png",
"CloseSelected.png", "CloseSelected.png",
this, this,
menu_selector(HelloWorld::menuCloseCallback) ); menu_selector(HelloWorld::menuCloseCallback));
pCloseItem->setPosition( ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20) ); if (CCApplication::sharedApplication().isIos() && !CCApplication::sharedApplication().isIpad())
{
pCloseItem->setPosition(ccp(visibleSize.width - 20 + origin.x, 20 + origin.y));
}
else
{
pCloseItem->setPosition(ccp(visibleSize.width - 40 + origin.x, 40 + origin.y));
}
// create menu, it's an autorelease object // create menu, it's an autorelease object
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL); CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
pMenu->setPosition( CCPointZero ); pMenu->setPosition(CCPointZero);
this->addChild(pMenu, 1); this->addChild(pMenu, 1);
///////////////////////////// /////////////////////////////
@ -50,11 +60,9 @@ bool HelloWorld::init()
// add a label shows "Hello World" // add a label shows "Hello World"
// create and initialize a label // create and initialize a label
CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Arial", 24); CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Arial", 24);
// ask director the window size
CCSize size = CCDirector::sharedDirector()->getWinSize();
// position the label on the center of the screen // position the label on the center of the screen
pLabel->setPosition( ccp(size.width / 2, size.height - 50) ); pLabel->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height - 50 + origin.y));
// add the label as a child to this layer // add the label as a child to this layer
this->addChild(pLabel, 1); this->addChild(pLabel, 1);
@ -63,7 +71,7 @@ bool HelloWorld::init()
CCSprite* pSprite = CCSprite::create("HelloWorld.png"); CCSprite* pSprite = CCSprite::create("HelloWorld.png");
// position the sprite on the center of the screen // position the sprite on the center of the screen
pSprite->setPosition( ccp(size.width/2, size.height/2) ); pSprite->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
// add the sprite as a child to this layer // add the sprite as a child to this layer
this->addChild(pSprite, 0); this->addChild(pSprite, 0);

View File

@ -0,0 +1 @@
e35126a63c774b4967e6b0e31082d7a32f58ed02

View File

@ -25,9 +25,7 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
if (!CCDirector::sharedDirector()->getOpenGLView()) if (!CCDirector::sharedDirector()->getOpenGLView())
{ {
CCEGLView *view = &CCEGLView::sharedOpenGLView(); CCEGLView *view = &CCEGLView::sharedOpenGLView();
view->setFrameSize(w, h); view->setSize(w, h);
// set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
// view->setDesignResolutionSize(480, 320);
AppDelegate *pAppDelegate = new AppDelegate(); AppDelegate *pAppDelegate = new AppDelegate();
CCApplication::sharedApplication().run(); CCApplication::sharedApplication().run();

View File

@ -7,17 +7,13 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
15003FA315D2601D00B6775A /* iphone in Resources */ = {isa = PBXBuildFile; fileRef = 15003FA215D2601D00B6775A /* iphone */; };
15003FA515D2602400B6775A /* iphonehd in Resources */ = {isa = PBXBuildFile; fileRef = 15003FA415D2602400B6775A /* iphonehd */; };
154269EB15B5669E00712A7F /* libcocos2dx.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 154269D015B5644500712A7F /* libcocos2dx.a */; }; 154269EB15B5669E00712A7F /* libcocos2dx.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 154269D015B5644500712A7F /* libcocos2dx.a */; };
15DD6D7A156DD120003E7567 /* fps_images.png in Resources */ = {isa = PBXBuildFile; fileRef = 15DD6D78156DD120003E7567 /* fps_images.png */; };
15F990B5159C0DAF00848A44 /* fps_images-hd.png in Resources */ = {isa = PBXBuildFile; fileRef = 15F990B3159C0DAF00848A44 /* fps_images-hd.png */; };
15F990B6159C0DAF00848A44 /* fps_images-ipadhd.png in Resources */ = {isa = PBXBuildFile; fileRef = 15F990B4159C0DAF00848A44 /* fps_images-ipadhd.png */; };
1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; };
288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765A40DF7441C002DB57D /* CoreGraphics.framework */; }; 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765A40DF7441C002DB57D /* CoreGraphics.framework */; };
782F4619153FEDF0009FC2E5 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 782F4617153FEDF0009FC2E5 /* Default.png */; }; 782F4619153FEDF0009FC2E5 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 782F4617153FEDF0009FC2E5 /* Default.png */; };
784521CE14EBA449009D533B /* CloseNormal.png in Resources */ = {isa = PBXBuildFile; fileRef = 784521C514EBA449009D533B /* CloseNormal.png */; };
784521CF14EBA449009D533B /* CloseSelected.png in Resources */ = {isa = PBXBuildFile; fileRef = 784521C614EBA449009D533B /* CloseSelected.png */; };
784521D214EBA449009D533B /* HelloWorld.png in Resources */ = {isa = PBXBuildFile; fileRef = 784521CA14EBA449009D533B /* HelloWorld.png */; };
BF1373EF128A898400D9F789 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF492D4B1289302400A09262 /* OpenGLES.framework */; }; BF1373EF128A898400D9F789 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF492D4B1289302400A09262 /* OpenGLES.framework */; };
BF1373F0128A899500D9F789 /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = BF492C21128924A800A09262 /* libxml2.dylib */; }; BF1373F0128A899500D9F789 /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = BF492C21128924A800A09262 /* libxml2.dylib */; };
BF1373F1128A899E00D9F789 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = BF492B6912891AC600A09262 /* libz.dylib */; }; BF1373F1128A899E00D9F789 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = BF492B6912891AC600A09262 /* libz.dylib */; };
@ -51,10 +47,9 @@
/* End PBXContainerItemProxy section */ /* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
15003FA215D2601D00B6775A /* iphone */ = {isa = PBXFileReference; lastKnownFileType = folder; path = iphone; sourceTree = "<group>"; };
15003FA415D2602400B6775A /* iphonehd */ = {isa = PBXFileReference; lastKnownFileType = folder; path = iphonehd; sourceTree = "<group>"; };
154269C815B5644500712A7F /* cocos2dx.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2dx.xcodeproj; path = ../../../cocos2dx/proj.ios/cocos2dx.xcodeproj; sourceTree = "<group>"; }; 154269C815B5644500712A7F /* cocos2dx.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2dx.xcodeproj; path = ../../../cocos2dx/proj.ios/cocos2dx.xcodeproj; sourceTree = "<group>"; };
15DD6D78156DD120003E7567 /* fps_images.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = fps_images.png; sourceTree = "<group>"; };
15F990B3159C0DAF00848A44 /* fps_images-hd.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "fps_images-hd.png"; sourceTree = "<group>"; };
15F990B4159C0DAF00848A44 /* fps_images-ipadhd.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "fps_images-ipadhd.png"; sourceTree = "<group>"; };
1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
1D6058910D05DD3D006BFB54 /* HelloCpp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HelloCpp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 1D6058910D05DD3D006BFB54 /* HelloCpp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HelloCpp.app; sourceTree = BUILT_PRODUCTS_DIR; };
1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
@ -63,9 +58,6 @@
781C33B31547F06B00633F88 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; 781C33B31547F06B00633F88 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
781C33B51547F06B00633F88 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; 781C33B51547F06B00633F88 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
782F4617153FEDF0009FC2E5 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = SOURCE_ROOT; }; 782F4617153FEDF0009FC2E5 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = SOURCE_ROOT; };
784521C514EBA449009D533B /* CloseNormal.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = CloseNormal.png; sourceTree = "<group>"; };
784521C614EBA449009D533B /* CloseSelected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = CloseSelected.png; sourceTree = "<group>"; };
784521CA14EBA449009D533B /* HelloWorld.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = HelloWorld.png; sourceTree = "<group>"; };
BF137426128A8E4600D9F789 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; BF137426128A8E4600D9F789 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
BF23D4E3143315EB00657E08 /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppDelegate.cpp; sourceTree = "<group>"; }; BF23D4E3143315EB00657E08 /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppDelegate.cpp; sourceTree = "<group>"; };
BF23D4E4143315EB00657E08 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; }; BF23D4E4143315EB00657E08 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
@ -153,17 +145,13 @@
784521C214EBA449009D533B /* Resources */ = { 784521C214EBA449009D533B /* Resources */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
15003FA415D2602400B6775A /* iphonehd */,
15003FA215D2601D00B6775A /* iphone */,
D4EF94ED15BD319D00D803EB /* Icon-144.png */, D4EF94ED15BD319D00D803EB /* Icon-144.png */,
D4EF94EB15BD319B00D803EB /* Icon-72.png */, D4EF94EB15BD319B00D803EB /* Icon-72.png */,
D4EF94E915BD319500D803EB /* Icon-114.png */, D4EF94E915BD319500D803EB /* Icon-114.png */,
D4EF94E715BD319200D803EB /* Icon-57.png */, D4EF94E715BD319200D803EB /* Icon-57.png */,
15F990B3159C0DAF00848A44 /* fps_images-hd.png */,
15F990B4159C0DAF00848A44 /* fps_images-ipadhd.png */,
15DD6D78156DD120003E7567 /* fps_images.png */,
782F4617153FEDF0009FC2E5 /* Default.png */, 782F4617153FEDF0009FC2E5 /* Default.png */,
784521C514EBA449009D533B /* CloseNormal.png */,
784521C614EBA449009D533B /* CloseSelected.png */,
784521CA14EBA449009D533B /* HelloWorld.png */,
); );
name = Resources; name = Resources;
path = ../Resources; path = ../Resources;
@ -259,17 +247,13 @@
isa = PBXResourcesBuildPhase; isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
784521CE14EBA449009D533B /* CloseNormal.png in Resources */,
784521CF14EBA449009D533B /* CloseSelected.png in Resources */,
784521D214EBA449009D533B /* HelloWorld.png in Resources */,
782F4619153FEDF0009FC2E5 /* Default.png in Resources */, 782F4619153FEDF0009FC2E5 /* Default.png in Resources */,
15DD6D7A156DD120003E7567 /* fps_images.png in Resources */,
15F990B5159C0DAF00848A44 /* fps_images-hd.png in Resources */,
15F990B6159C0DAF00848A44 /* fps_images-ipadhd.png in Resources */,
D4EF94E815BD319200D803EB /* Icon-57.png in Resources */, D4EF94E815BD319200D803EB /* Icon-57.png in Resources */,
D4EF94EA15BD319500D803EB /* Icon-114.png in Resources */, D4EF94EA15BD319500D803EB /* Icon-114.png in Resources */,
D4EF94EC15BD319B00D803EB /* Icon-72.png in Resources */, D4EF94EC15BD319B00D803EB /* Icon-72.png in Resources */,
D4EF94EE15BD319D00D803EB /* Icon-144.png in Resources */, D4EF94EE15BD319D00D803EB /* Icon-144.png in Resources */,
15003FA315D2601D00B6775A /* iphone in Resources */,
15003FA515D2602400B6775A /* iphonehd in Resources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };

View File

@ -24,9 +24,7 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
if (!CCDirector::sharedDirector()->getOpenGLView()) if (!CCDirector::sharedDirector()->getOpenGLView())
{ {
CCEGLView *view = &CCEGLView::sharedOpenGLView(); CCEGLView *view = &CCEGLView::sharedOpenGLView();
view->setFrameSize(w, h); view->setSize(w, h);
// set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
view->setDesignResolutionSize(480, 320);
AppDelegate *pAppDelegate = new AppDelegate(); AppDelegate *pAppDelegate = new AppDelegate();
CCApplication::sharedApplication().run(); CCApplication::sharedApplication().run();

View File

@ -25,9 +25,7 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
if (!CCDirector::sharedDirector()->getOpenGLView()) if (!CCDirector::sharedDirector()->getOpenGLView())
{ {
CCEGLView *view = &CCEGLView::sharedOpenGLView(); CCEGLView *view = &CCEGLView::sharedOpenGLView();
view->setFrameSize(w, h); view->setSize(w, h);
// set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
// view->setDesignResolutionSize(480, 320);
AppDelegate *pAppDelegate = new AppDelegate(); AppDelegate *pAppDelegate = new AppDelegate();
CCApplication::sharedApplication().run(); CCApplication::sharedApplication().run();

View File

@ -25,9 +25,7 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
if (!CCDirector::sharedDirector()->getOpenGLView()) if (!CCDirector::sharedDirector()->getOpenGLView())
{ {
CCEGLView *view = &CCEGLView::sharedOpenGLView(); CCEGLView *view = &CCEGLView::sharedOpenGLView();
view->setFrameSize(w, h); view->setSize(w, h);
// set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
// view->setDesignResolutionSize(480, 320);
AppDelegate *pAppDelegate = new AppDelegate(); AppDelegate *pAppDelegate = new AppDelegate();
CCApplication::sharedApplication().run(); CCApplication::sharedApplication().run();