revert back SimpleGame to enableRetinaDisplay approach. Update background image of HelloCpp to 640x1136.

This commit is contained in:
walzer 2012-09-24 21:14:08 +08:00
parent ea9c183473
commit 609c4b12f9
4 changed files with 6 additions and 22 deletions

View File

@ -1 +1 @@
e35126a63c774b4967e6b0e31082d7a32f58ed02
6b7a2544be32ce26e75737865743649598d83bdf

View File

@ -31,17 +31,15 @@ bool AppDelegate::applicationDidFinishLaunching() {
}
else if (target == kTargetIphone)
{
if (CCEGLView::sharedOpenGLView()->enableRetina())
if (CCDirector::sharedDirector()->enableRetinaDisplay(true))
{
// well, it's a iPhone 4 and above, with 960x480 Retina resolution
// well, it's a iPhone 4, iPhone 4S or iPhone 5
CCFileUtils::sharedFileUtils()->setResourceDirectory("hd");
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(960, 640, kResolutionNoBorder);
}
else
{
// iPhone 3GS and before, with 480x320 resolution
CCFileUtils::sharedFileUtils()->setResourceDirectory("sd");
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(480, 320, kResolutionNoBorder);
}
}
else

View File

@ -4,8 +4,6 @@
using namespace cocos2d;
extern float g_scaleRatio;
HelloWorld::~HelloWorld()
{
if (_targets)
@ -28,18 +26,7 @@ HelloWorld::HelloWorld()
:_targets(NULL)
,_projectiles(NULL)
,_projectilesDestroyed(0)
,_scaleRatio(1.0)
{
if ( 0 == strcmp(CCFileUtils::sharedFileUtils()->getResourceDirectory(), "hd/") )
{
// AppDelegate.cpp used hd resource & 960x640 design resolution
_scaleRatio = 2.0;
}
else
{
// sd
_scaleRatio = 1.0;
}
}
CCScene* HelloWorld::scene()
@ -106,7 +93,7 @@ bool HelloWorld::init()
/////////////////////////////
// 2. add your codes below...
CCSprite *player = CCSprite::create("Player.png", CCRectMake(0, 0, 27*_scaleRatio, 40*_scaleRatio) );
CCSprite *player = CCSprite::create("Player.png", CCRectMake(0, 0, 27, 40) );
player->setPosition( ccp(origin.x + player->getContentSize().width/2,
origin.y + visibleSize.height/2) );
@ -140,7 +127,7 @@ void HelloWorld::menuCloseCallback(CCObject* pSender)
// cpp with cocos2d-x
void HelloWorld::addTarget()
{
CCSprite *target = CCSprite::create("Target.png", CCRectMake(0,0,27*_scaleRatio,40*_scaleRatio) );
CCSprite *target = CCSprite::create("Target.png", CCRectMake(0,0,27,40) );
// Determine where to spawn the target along the Y axis
CCSize winSize = CCDirector::sharedDirector()->getVisibleSize();
@ -212,7 +199,7 @@ void HelloWorld::ccTouchesEnded(CCSet* touches, CCEvent* event)
// Set up initial location of projectile
CCSize winSize = CCDirector::sharedDirector()->getVisibleSize();
CCSprite *projectile = CCSprite::create("Projectile.png", CCRectMake(0, 0, 20*_scaleRatio, 20*_scaleRatio));
CCSprite *projectile = CCSprite::create("Projectile.png", CCRectMake(0, 0, 20, 20));
projectile->setPosition( ccp(20, winSize.height/2) );
// Determinie offset of location to projectile

View File

@ -38,7 +38,6 @@ protected:
cocos2d::CCArray *_targets;
cocos2d::CCArray *_projectiles;
int _projectilesDestroyed;
float _scaleRatio;
void addTarget();