经过长时间和许多小时的开发,仅在使用 Visual Studio 2012 的 windows opengl 模拟器上,每件事看起来都应该在 480/320 屏幕尺寸上进行测试
CCSize screenSize = pEGLView->getFrameSize();
CCSize designSize = CCSize(320, 480);
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionShowAll);
if (screenSize.width > 640) {
CCFileUtils::sharedFileUtils()->addSearchPath("ipadhd");
pDirector->setContentScaleFactor(1280/designSize.width);
} else if (screenSize.width > 320) {
CCFileUtils::sharedFileUtils()->addSearchPath("ipad");
pDirector->setContentScaleFactor(640/designSize.width);
} else {
CCFileUtils::sharedFileUtils()->addSearchPath("iphone");
pDirector->setContentScaleFactor(320/designSize.width);
}
并使用此功能加载图像
void GameLayer::loadImages()
{
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("sprites35.plist");
m_gameBatchNode = CCSpriteBatchNode::create("sprites.png",200);
this->addChild(m_gameBatchNode,2,kSSheet);
m_background = CCSprite::create("gride300_300.png");
m_background->setPosition(ccp(m_winSize.width/2,m_winSize.height/2));
this->addChild(m_background,kGrid);
}
当我第一次在我的设备(iPhone 5)中运行该应用程序时,所有尺寸的图像都变小了 1/3,而且位置都错了。
我的问题是我如何使用开放的GL
模拟器在 Windows 上进行开发,并且仍然可以在我的 iPhone 5
更新
上看到所有内容它是这样的:
m_background = CCSprite::create("gride300_300.png");
m_background->setPosition(ccp(m_winSize.width/2,m_winSize.height/2));
this->addChild(m_background,kGrid);
在模拟器中看起来很棒。但是当我在 iPhone 上看到它时,它在中间但很小。不像在模拟器中
第二个例子:
我放置圆形宝石,尺寸:35 x 35 像素(1.00),每个放置在中间,也一个接一个,它们在模拟器中看起来都很棒,但是当我在 iPhone 中看到它时,它们又非常小
并且对齐在屏幕的左下角,
这里是放置宝石的代码:
void Gem::placeInGride()
{
CCSpriteBatchNode *spriteBatchNode = (CCSpriteBatchNode*) getGameController()->getGameLayer()->getChildByTag(kSSheet);
int gemSelect =(rand() % totalGemsAvailable) + 1;
GemType gemNum;
gemNum =(GemType)gemSelect;
setGemState(kGemNew);
char spritename[20];
sprintf(spritename,"gem%i_tranc.png",gemNum);
setImageName(spritename);
setGemType(gemNum);
char spriteid[20];
sprintf(spriteid,"gem_%i_%i",getRowNum(),getColNum());
std::string gemid(spriteid);
setGemId(spriteid);
mySprite = CCSprite::createWithSpriteFrameName(spritename);
mySprite->setOpacity(255);
spriteBatchNode->addChild(mySprite, 2);
CCSize sSize = mySprite->getContentSize();
setGemPosition(setPositionForGem(getRowNum(),getColNum(),sSize));
}
CCPoint Gem::setPositionForGem(int row,int col,const CCSize& gemSize)
{
float leftPadding = 30 ;
float rightPadding = 37.5 ;
float topPadding = 111.5;
float buttonPadding = 90;
float gemHight = gemSize.height;
float gemWidth = gemSize.width;
float x = (leftPadding+1) + ((gemWidth+2)*(col));
float y = (topPadding+1) + ((gemHight+2)*(row/*+1*/));
return ccp(x,y) ;
}
m 附加来自我的 iPhone 和 Windows 的屏幕截图