Added support for resolutionScale.

This commit is contained in:
Nicolas Gramlich 2012-06-04 16:16:42 -07:00
parent 28862c30cf
commit d3e0f8dc92
3 changed files with 31 additions and 14 deletions

View File

@ -15,6 +15,10 @@
#include "CCControlButtonLoader.h"
#include "CCParticleSystemQuadLoader.h"
#ifdef __CC_PLATFORM_IOS
#import <UIKit/UIDevice.h>
#endif
using namespace cocos2d;
using namespace cocos2d::extension;
@ -22,6 +26,15 @@ CCBReader::CCBReader(CCBMemberVariableAssigner * pCCBMemberVariableAssigner, CCB
this->mCCBMemberVariableAssigner = pCCBMemberVariableAssigner;
this->mCCBSelectorResolver = pCCBSelectorResolver;
this->mResolutionScale = 1;
#ifdef __CC_PLATFORM_IOS
/* iPad */
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
this->mResolutionScale = 2;
}
#endif
this->registerCCNodeLoader("CCNode", new CCNodeLoader());
this->registerCCNodeLoader("CCLayer", new CCLayerLoader());
this->registerCCNodeLoader("CCLayerColor", new CCLayerColorLoader());
@ -47,7 +60,8 @@ CCBReader::~CCBReader() {
}
CCBReader::CCBReader(CCBReader * pCCBReader) {
/* Borrow CCNodeLoaders and LoadedSpriteSheets. */
/* Borrow data from the 'parent' CCBLoader. */
this->mResolutionScale = pCCBReader->mResolutionScale;
this->mLoadedSpriteSheets = pCCBReader->mLoadedSpriteSheets;
this->mCCNodeLoaders = pCCBReader->mCCNodeLoaders;
this->mCCBMemberVariableAssigner = pCCBReader->mCCBMemberVariableAssigner;
@ -66,6 +80,10 @@ CCBSelectorResolver * CCBReader::getCCBSelectorResolver() {
return this->mCCBSelectorResolver;
}
float CCBReader::getResolutionScale() {
return this->mResolutionScale;
}
CCNodeLoader * CCBReader::getCCNodeLoader(std::string pClassName) {
std::map<std::string, CCNodeLoader *>::iterator ccNodeLoadersIterator = this->mCCNodeLoaders.find(pClassName);
assert(ccNodeLoadersIterator != this->mCCNodeLoaders.end());

View File

@ -82,6 +82,7 @@ class CC_DLL CCBReader : public CCObject { // TODO Why extend CCObject? -> Also
CCObject * mOwner;
CCNode * mRootNode;
CCSize mRootContainerSize;
float mResolutionScale;
CCBMemberVariableAssigner * mCCBMemberVariableAssigner;
CCBSelectorResolver * mCCBSelectorResolver;
@ -107,14 +108,18 @@ class CC_DLL CCBReader : public CCObject { // TODO Why extend CCObject? -> Also
CCObject * getOwner();
CCNode * getRootNode();
CCSize getContainerSize(CCNode *);
float getResolutionScale();
bool isSpriteSheetLoaded(std::string);
void addLoadedSpriteSheet(std::string);
/* Utility methods. */
std::string lastPathComponent(std::string);
std::string deletePathExtension(std::string);
std::string toLowerCase(std::string);
bool endsWith(std::string, std::string);
bool isSpriteSheetLoaded(std::string);
void addLoadedSpriteSheet(std::string);
/* Parse methods */
/* Parse methods. */
int readInt(bool pSign);
unsigned char readByte();
bool readBool();

View File

@ -350,13 +350,10 @@ float * CCNodeLoader::parsePropTypeScaleLock(CCNode * pNode, CCNode * pParent, C
int type = pCCBReader->readInt(false);
// TODO
/*
if (type == kCCBScaleTypeMultiplyResolution) {
x *= resolutionScale;
y *= resolutionScale;
x *= pCCBReader->getResolutionScale();
y *= pCCBReader->getResolutionScale();
}
*/
float * scaleLock = new float[2];
scaleLock[0] = x;
@ -378,13 +375,10 @@ float CCNodeLoader::parsePropTypeFloatScale(CCNode * pNode, CCNode * pParent, CC
int type = pCCBReader->readInt(false);
// TODO
/*
if (type == kCCBScaleTypeMultiplyResolution) {
x *= resolutionScale;
y *= resolutionScale;
f *= pCCBReader->getResolutionScale();
}
*/
return f;
}