do some bug fixes

This commit is contained in:
minggo 2012-12-04 18:44:32 +08:00
parent 9617d5cba3
commit 58a187f774
3 changed files with 50 additions and 43 deletions

View File

@ -134,9 +134,9 @@ CCBReader::~CCBReader() {
this->mCCNodeLoaderLibrary->release();
mOwnerOutletNodes->release();
mOwnerOutletNames.clear();
mOwnerCallbackNodes->release();
mOwnerOutletNodes->release();
mOwnerOutletNames.clear();
mOwnerCallbackNodes->release();
mOwnerCallbackNames.clear();
// Clear string cache.
@ -292,13 +292,13 @@ CCNode* CCBReader::readNodeGraphFromData(CCData *pData, CCObject *pOwner, const
CCDICT_FOREACH(animationManagers, pElement)
{
CCNode* pNode = (CCNode*)pElement->getIntKey();
CCBAnimationManager* manager = (CCBAnimationManager*)animationManagers->objectForKey((intptr_t)pNode);
pNode->setUserObject(manager);
if (jsControlled)
{
mNodesWithAnimationManagers->addObject(pNode);
mAnimationManagersForNodes->addObject(manager);
CCBAnimationManager* manager = (CCBAnimationManager*)animationManagers->objectForKey((intptr_t)pNode);
pNode->setUserObject(manager);
if (jsControlled)
{
mNodesWithAnimationManagers->addObject(pNode);
mAnimationManagersForNodes->addObject(manager);
}
}
@ -414,24 +414,24 @@ bool CCBReader::readBool() {
return 0 == this->readByte() ? false : true;
}
std::string CCBReader::readUTF8()
{
std::string ret;
int b0 = this->readByte();
int b1 = this->readByte();
int numBytes = b0 << 8 | b1;
char* pStr = (char*)malloc(numBytes+1);
memcpy(pStr, mBytes+mCurrentByte, numBytes);
pStr[numBytes] = '\0';
ret = pStr;
free(pStr);
mCurrentByte += numBytes;
return ret;
std::string CCBReader::readUTF8()
{
std::string ret;
int b0 = this->readByte();
int b1 = this->readByte();
int numBytes = b0 << 8 | b1;
char* pStr = (char*)malloc(numBytes+1);
memcpy(pStr, mBytes+mCurrentByte, numBytes);
pStr[numBytes] = '\0';
ret = pStr;
free(pStr);
mCurrentByte += numBytes;
return ret;
}
bool CCBReader::getBit() {
@ -908,15 +908,7 @@ CCArray* CCBReader::getAnimationManagersForNodes() {
float CCBReader::getResolutionScale()
{
// Init resolution scale
if (CCApplication::sharedApplication()->getTargetPlatform() == kTargetIpad)
{
return 2;
}
else
{
return 1;
}
return 1;
}
NS_CC_EXT_END;

View File

@ -25,18 +25,32 @@ bool AppDelegate::applicationDidFinishLaunching()
// initialize director
CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
pDirector->setProjection(kCCDirectorProjection2D);
CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize();
CCSize designSize = CCSizeMake(320, 480);
CCSize resourceSize = CCSizeMake(320, 480);
// if (screenSize.height > 320)
// {
// CCSize resourceSize = CCSizeMake(640, 960);
// CCFileUtils::sharedFileUtils()->setResourceDirectory("hd");
// pDirector->setContentScaleFactor(resourceSize.height/designSize.height);
// }
if (screenSize.height > 768)
{
resourceSize = CCSizeMake(1536, 2048);
CCFileUtils::sharedFileUtils()->setResourceDirectory("resources-ipadhd");
}
else if (screenSize.height > 640)
{
resourceSize = CCSizeMake(768, 1536);
CCFileUtils::sharedFileUtils()->setResourceDirectory("resources-ipad");
}
else if (screenSize.height > 320)
{
resourceSize = CCSizeMake(640, 960);
CCFileUtils::sharedFileUtils()->setResourceDirectory("resources-iphonehd");
}
pDirector->setContentScaleFactor(resourceSize.height/designSize.height);
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionNoBorder);

View File

@ -24,6 +24,7 @@ bool AppDelegate::applicationDidFinishLaunching()
// initialize director
CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
pDirector->setProjection(kCCDirectorProjection2D);
// Set the design resolution
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(320, 480, kResolutionShowAll);