Reputation: 30925
after long and many hours of development only on the windows opengl simulator using visual studio 2012 every thing looked like it should be i tested on 480/320 screen size
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);
}
and with this function that loads the images
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);
}
when i first run the app in my device ( iPhone 5 )
all sizes of the images got 1/3 smaller and the position was all wrong .
my question is how can i develop on windows using the open GL simulator and still to see every thing right on my iPhone 5
UPDATE
i will give more info
for example i have background image that is 297 x 297 Pixels (1.00) in size
i place it like this :
m_background = CCSprite::create("gride300_300.png");
m_background->setPosition(ccp(m_winSize.width/2,m_winSize.height/2));
this->addChild(m_background,kGrid);
in the simulator it looks great . but when i see it in the iPhone it in the middle but very small . not like in the simulator
second example:
i place round gems with size : 35 x 35 Pixels (1.00) each to place in the middle also
one after the other they all look great in the simulator but when i see it in the iPhone they are again very small
and align to the bottom left of the screen ,
here is the code to place the gems :
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 attaching screen shots both from my iPhone and windows
iphone_screen.PNG
windos_screen.jpg
Upvotes: 1
Views: 940
Reputation: 11872
I think you have your parameters backward for
CCSize designSize = CCSize(320, 480);
should be
CCSize designSize = CCSize(480,320);
also have you tried using
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
to verify the actual screen size being used for the device
then then providing scaled images from there like in this example that uses the iphone, ipad and ipadhd.
Upvotes: 0