mirror of https://github.com/axmolengine/axmol.git
Added CCScale9SpriteLoader.
This commit is contained in:
parent
948fcc3d07
commit
8a01e33491
|
@ -138,9 +138,11 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader *
|
|||
break;
|
||||
}
|
||||
case kCCBPropTypeSpriteFrame: {
|
||||
CCSpriteFrame * ccSpriteFrame = this->parsePropTypeSpriteFrame(pNode, pParent, pCCBReader);
|
||||
if(setProp) {
|
||||
this->onHandlePropTypeSpriteFrame(pNode, pParent, propertyName, this->parsePropTypeSpriteFrame(pNode, pParent, pCCBReader), pCCBReader);
|
||||
this->onHandlePropTypeSpriteFrame(pNode, pParent, propertyName, ccSpriteFrame, pCCBReader);
|
||||
}
|
||||
// TODO delete ccSpriteFrame; ???
|
||||
break;
|
||||
}
|
||||
case kCCBPropTypeAnimation: {
|
||||
|
@ -156,7 +158,7 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader *
|
|||
if(setProp) {
|
||||
this->onHandlePropTypeTexture(pNode, pParent, propertyName, ccTexture2D, pCCBReader);
|
||||
}
|
||||
|
||||
// TODO delete ccTexture2D; ???
|
||||
break;
|
||||
}
|
||||
case kCCBPropTypeByte: {
|
||||
|
|
|
@ -4,19 +4,23 @@ using namespace cocos2d;
|
|||
using namespace cocos2d::extension;
|
||||
|
||||
#define PROPERTY_CONTENTSIZE "contentSize"
|
||||
#define PROPERTY_DISPLAYFRAME "displayFrame"
|
||||
#define PROPERTY_SPRITEFRAME "spriteFrame"
|
||||
#define PROPERTY_COLOR "color"
|
||||
#define PROPERTY_OPACITY "opacity"
|
||||
#define PROPERTY_BLENDFUNC "blendFunc"
|
||||
#define PROPERTY_DIMENSIONS "dimensions"
|
||||
#define PROPERTY_PREFEREDSIZE "preferedSize" // TODO Should be "preferredSize". This is a typo in cocos2d-iphone, cocos2d-x and CocosBuilder!
|
||||
#define PROPERTY_INSETLEFT "insetLeft"
|
||||
#define PROPERTY_INSETTOP "insetTop"
|
||||
#define PROPERTY_INSETRIGHT "insetRight"
|
||||
#define PROPERTY_INSETBOTTOM "insetBottom"
|
||||
|
||||
CCScale9Sprite * CCScale9SpriteLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) {
|
||||
return CCScale9Sprite::node();
|
||||
}
|
||||
|
||||
void CCScale9SpriteLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) {
|
||||
if(pPropertyName.compare(PROPERTY_DISPLAYFRAME) == 0) {
|
||||
((CCSprite *)pNode)->setDisplayFrame(pCCSpriteFrame);
|
||||
if(pPropertyName.compare(PROPERTY_SPRITEFRAME) == 0) {
|
||||
((CCScale9Sprite *)pNode)->initWithSpriteFrame(pCCSpriteFrame);
|
||||
} else {
|
||||
CCNodeLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pCCSpriteFrame, pCCBReader);
|
||||
}
|
||||
|
@ -49,10 +53,24 @@ void CCScale9SpriteLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pP
|
|||
|
||||
void CCScale9SpriteLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCSize pSize, CCBReader * pCCBReader) {
|
||||
if(pPropertyName.compare(PROPERTY_CONTENTSIZE) == 0) {
|
||||
((CCScale9Sprite *)pNode)->setContentSize(pSize);
|
||||
} else if(pPropertyName.compare(PROPERTY_DIMENSIONS) == 0) {
|
||||
((CCScale9Sprite *)pNode)->setContentSize(pSize);
|
||||
//((CCScale9Sprite *)pNode)->setContentSize(pSize);
|
||||
} else if(pPropertyName.compare(PROPERTY_PREFEREDSIZE) == 0) {
|
||||
((CCScale9Sprite *)pNode)->setPreferredSize(pSize);
|
||||
} else {
|
||||
CCNodeLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, pSize, pCCBReader);
|
||||
}
|
||||
}
|
||||
|
||||
void CCScale9SpriteLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, std::string pPropertyName, float pFloat, CCBReader * pCCBReader) {
|
||||
if(pPropertyName.compare(PROPERTY_INSETLEFT) == 0) {
|
||||
((CCScale9Sprite *)pNode)->setInsetLeft(pFloat);
|
||||
} else if(pPropertyName.compare(PROPERTY_INSETTOP) == 0) {
|
||||
((CCScale9Sprite *)pNode)->setInsetTop(pFloat);
|
||||
} else if(pPropertyName.compare(PROPERTY_INSETRIGHT) == 0) {
|
||||
((CCScale9Sprite *)pNode)->setInsetRight(pFloat);
|
||||
} else if(pPropertyName.compare(PROPERTY_INSETBOTTOM) == 0) {
|
||||
((CCScale9Sprite *)pNode)->setInsetBottom(pFloat);
|
||||
} else {
|
||||
CCNodeLoader::onHandlePropTypeFloat(pNode, pParent, pPropertyName, pFloat, pCCBReader);
|
||||
}
|
||||
}
|
|
@ -17,6 +17,7 @@ class CCScale9SpriteLoader : public CCNodeLoader {
|
|||
virtual void onHandlePropTypeBlendFunc(CCNode *, CCNode *, std::string, ccBlendFunc, CCBReader *);
|
||||
virtual void onHandlePropTypeSpriteFrame(CCNode *, CCNode *, std::string, CCSpriteFrame *, CCBReader *);
|
||||
virtual void onHandlePropTypeSize(CCNode *, CCNode *, std::string, CCSize, CCBReader *);
|
||||
virtual void onHandlePropTypeFloat(CCNode *, CCNode *, std::string, float, CCBReader *);
|
||||
};
|
||||
|
||||
NS_CC_EXT_END
|
||||
|
|
Loading…
Reference in New Issue