Skip to content

fix 5 bugs: #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
2 commits merged into from
Mar 11, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions cocos2dx/platform/CCDirector_mobile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -790,13 +790,12 @@ bool CCDirector::enableRetinaDisplay(bool enabled)
return false;
}

///@todo SD device iphone specific
// if ([[UIScreen mainScreen] scale] == 1.0)
// return NO;

float newScale = (float)(enabled ? 2 : 1);
setContentScaleFactor(newScale);

// release cached texture
CCTextureCache::purgeSharedTextureCache();

#if CC_DIRECTOR_FAST_FPS
if (m_pFPSLabel)
{
Expand Down
11 changes: 9 additions & 2 deletions cocos2dx/platform/win32/CCEGLView_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ LRESULT CCEGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
POINT pt = {LOWORD(lParam), HIWORD(lParam)};
if (PtInRect(&m_rcViewPort, pt))
{
CCLog("mlbd:(%d, %d)", pt.x, pt.y);
m_bCaptured = true;
m_pTouch->SetTouchInfo(0, (float)(pt.x - m_rcViewPort.left) / m_fScreenScaleFactor,
(float)(pt.y - m_rcViewPort.top) / m_fScreenScaleFactor);
Expand Down Expand Up @@ -506,7 +505,15 @@ bool CCEGLView::canSetContentScaleFactor()
void CCEGLView::setContentScaleFactor(float contentScaleFactor)
{
m_fScreenScaleFactor = contentScaleFactor;
resize((int)(m_tSizeInPoints.cx * contentScaleFactor), (int)(m_tSizeInPoints.cy * contentScaleFactor));
if (m_bOrientationReverted)
{
resize((int)(m_tSizeInPoints.cy * contentScaleFactor), (int)(m_tSizeInPoints.cx * contentScaleFactor));
}
else
{
resize((int)(m_tSizeInPoints.cx * contentScaleFactor), (int)(m_tSizeInPoints.cy * contentScaleFactor));
}
centerWindow();
}

CCEGLView& CCEGLView::sharedOpenGLView()
Expand Down
4 changes: 2 additions & 2 deletions cocos2dx/proj.win32/cocos2d-win32.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
/>
<Tool
Name="VCPreLinkEventTool"
CommandLine="if not exist $(OutDir) mkdir $(OutDir)&#x0D;&#x0A;xcopy /Y /Q $(SolutionDir)cocos2dx\platform\third_party\win32\libraries\*.* $(OutDir)"
CommandLine="if not exist &quot;$(OutDir)&quot; mkdir &quot;$(OutDir)&quot;&#x0D;&#x0A;xcopy /Y /Q &quot;$(SolutionDir)cocos2dx\platform\third_party\win32\libraries\*.*&quot; &quot;$(OutDir)&quot;&#x0D;&#x0A;"
/>
<Tool
Name="VCLinkerTool"
Expand Down Expand Up @@ -141,7 +141,7 @@
/>
<Tool
Name="VCPreLinkEventTool"
CommandLine="if not exist $(OutDir) mkdir $(OutDir)&#x0D;&#x0A;xcopy /Y /Q $(SolutionDir)cocos2dx\platform\third_party\win32\libraries\*.* $(OutDir)"
CommandLine="if not exist &quot;$(OutDir)&quot; mkdir &quot;$(OutDir)&quot;&#x0D;&#x0A;xcopy /Y /Q &quot;$(SolutionDir)cocos2dx\platform\third_party\win32\libraries\*.*&quot; &quot;$(OutDir)&quot;&#x0D;&#x0A;"
/>
<Tool
Name="VCLinkerTool"
Expand Down
3 changes: 2 additions & 1 deletion cocos2dx/textures/CCTextureCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,10 @@ CCTexture2D * CCTextureCache::addImage(const char * path)
std::string pathKey = path;
CCFileUtils::ccRemoveHDSuffixFromFile(pathKey);

pathKey = CCFileUtils::fullPathFromRelativePath(pathKey.c_str());
texture = m_pTextures->objectForKey(pathKey);

std::string fullpath(CCFileUtils::fullPathFromRelativePath(path));
std::string fullpath = pathKey; // (CCFileUtils::fullPathFromRelativePath(path));
if( ! texture )
{
std::string lowerCase(path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ function AddConfigurations(proj, strProjectName) {
// Post-build settings
var PostBuildTool = config.Tools("VCPostBuildEventTool");
PostBuildTool.Description = "Performing copy resource from Resource to OutDir...";
PostBuildTool.CommandLine = "copy /Y \"$(ProjectDir)Resource\\*.*\" \"$(OutDir)\"";
PostBuildTool.CommandLine = "xcopy /E /Q /Y \"$(ProjectDir)Resource\\*.*\" \"$(OutDir)\"";
}
}
catch (e) {
Expand Down
23 changes: 23 additions & 0 deletions tests/tests/HiResTest/HiResTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,17 @@ void HiResDemo::backCallback(CCObject* pSender)
///////////////////////////////////
void HiResTest1::onEnter()
{
CCDirector::sharedDirector()->enableRetinaDisplay(false);
// Because BackToMainMenuLayer maybe addChild to scene again by HiResTest2,
// we add it again to make it in the right place.
// The right way is calling enableRetinaDisplay before all scene and layer.
CCScene * pScene = (CCScene*)getParent();
CCLayer* pLayer = (CCLayer*)pScene->getChildByTag(54321);
pScene->removeChild(pLayer, true);
pLayer = new BackToMainMenuLayer;
pScene->addChild(pLayer, 1000, 54321);
pLayer->release();

HiResDemo::onEnter();

CCSize size = CCDirector::sharedDirector()->getWinSize();
Expand All @@ -169,6 +180,18 @@ std::string HiResTest1::subtitle()
///////////////////////////////////
void HiResTest2::onEnter()
{
CCDirector::sharedDirector()->enableRetinaDisplay(true);

// Because BackToMainMenuLayer has been addChild to scene,
// we must add it again.
// The right way is calling enableRetinaDisplay before all scene and layer.
CCScene * pScene = (CCScene*)getParent();
CCLayer* pLayer = (CCLayer*)pScene->getChildByTag(54321);
pScene->removeChild(pLayer, true);
pLayer = new BackToMainMenuLayer;
pScene->addChild(pLayer, 1000, 54321);
pLayer->release();

HiResDemo::onEnter();

CCSize size = CCDirector::sharedDirector()->getWinSize();
Expand Down
5 changes: 4 additions & 1 deletion tests/tests/testBasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ BackToMainMenuLayer::BackToMainMenuLayer()

void BackToMainMenuLayer::MainMenuCallback(CCObject* pSender)
{
CCDirector::sharedDirector()->enableRetinaDisplay(false);

CCScene* pScene = CCScene::node();
CCLayer* pLayer = new TestController();
pLayer->autorelease();
Expand All @@ -31,5 +33,6 @@ TestScene::TestScene()
CCLayer* pLayer = new BackToMainMenuLayer();
pLayer->autorelease();

addChild(pLayer, 1000);
// 54321 is the tag of BackToMainMenuLayer
addChild(pLayer, 1000, 54321);
}