mirror of https://github.com/axmolengine/axmol.git
Added support for resolutionScale.
This commit is contained in:
parent
28862c30cf
commit
d3e0f8dc92
|
@ -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());
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue