issue #1470:fix some logical errors

This commit is contained in:
minggo 2012-09-18 17:04:10 +08:00
parent 4b969e35c8
commit a0feb5f289
4 changed files with 30 additions and 55 deletions

View File

@ -299,7 +299,7 @@ void CCBAnimationManager::setAnimatedProperty(const char *pPropName, CCNode *pNo
}
else if (strcmp(pPropName, "scale") == 0)
{
// Get position type
// Get scale type
CCArray *array = (CCArray*)getBaseValue(pNode, pPropName);
int type = ((CCBValue*)array->objectAtIndex(2))->getIntValue();
@ -314,7 +314,7 @@ void CCBAnimationManager::setAnimatedProperty(const char *pPropName, CCNode *pNo
{
// [node setValue:value forKey:name];
// TODO only handle rotation, opacity,
// TODO only handle rotation, opacity, displayFrame, color
if (strcmp(pPropName, "rotation") == 0)
{
float rotate = ((CCBValue*)pValue)->getFloatValue();
@ -374,7 +374,7 @@ CCActionInterval* CCBAnimationManager::getEaseAction(CCActionInterval *pAction,
}
else if (nEasingType == kCCBKeyframeEasingCubicOut)
{
return CCEaseInOut::create(pAction, fEasingOpt);
return CCEaseOut::create(pAction, fEasingOpt);
}
else if (nEasingType == kCCBKeyframeEasingCubicInOut)
{
@ -485,9 +485,9 @@ void CCBAnimationManager::runAnimations(int nSeqId, float fTweenDuration)
CCDictElement* pElement1 = NULL;
CCDICT_FOREACH(seqNodeProps, pElement1)
{
const char *propNmae = pElement1->getStrKey();
CCBSequenceProperty *seqProp = (CCBSequenceProperty*)seqNodeProps->objectForKey(propNmae);
seqNodePropNames.insert(propNmae);
const char *propName = pElement1->getStrKey();
CCBSequenceProperty *seqProp = (CCBSequenceProperty*)seqNodeProps->objectForKey(propName);
seqNodePropNames.insert(propName);
setFirstFrame(node, seqProp, fTweenDuration);
runAction(node, seqProp, fTweenDuration);
@ -501,13 +501,13 @@ void CCBAnimationManager::runAnimations(int nSeqId, float fTweenDuration)
CCDictElement* pElement2 = NULL;
CCDICT_FOREACH(nodeBaseValues, pElement2)
{
if (seqNodePropNames.find(pElement2->getStrKey()) != seqNodePropNames.end())
if (seqNodePropNames.find(pElement2->getStrKey()) == seqNodePropNames.end())
{
CCObject *value = pElement2->getObject();
if (value)
{
setAnimatedProperty(pElement2->getStrKey(), node, value, fTweenDuration);
setAnimatedProperty(pElement2->getStrKey(), node, value, fTweenDuration);
}
}
}

View File

@ -64,6 +64,7 @@ CCBReader::CCBReader(CCNodeLoaderLibrary * pCCNodeLoaderLibrary, CCBMemberVariab
, mCurrentBit(-1)
, mOwner(NULL)
, mActionManager(NULL)
, mAnimatedProps(NULL)
{
this->mCCNodeLoaderLibrary = pCCNodeLoaderLibrary;
this->mCCNodeLoaderLibrary->retain();
@ -79,6 +80,7 @@ CCBReader::CCBReader(CCBReader * pCCBReader)
, mCurrentBit(-1)
, mOwner(NULL)
, mActionManager(NULL)
, mAnimatedProps(NULL)
{
this->mLoadedSpriteSheets = pCCBReader->mLoadedSpriteSheets;
this->mCCNodeLoaderLibrary = pCCBReader->mCCNodeLoaderLibrary;
@ -100,6 +102,7 @@ CCBReader::CCBReader()
, mCCNodeLoaderListener(NULL)
, mCCBMemberVariableAssigner(NULL)
, mCCBSelectorResolver(NULL)
, mAnimatedProps(NULL)
{}
CCBReader::~CCBReader() {
@ -161,7 +164,7 @@ CCBSelectorResolver * CCBReader::getCCBSelectorResolver() {
return this->mCCBSelectorResolver;
}
set<string>& CCBReader::getAnimatedProperties()
set<string>* CCBReader::getAnimatedProperties()
{
return mAnimatedProps;
}
@ -477,6 +480,7 @@ CCNode * CCBReader::readNodeGraph(CCNode * pParent) {
// Read animated properties
CCDictionary *seqs = CCDictionary::create();
mAnimatedProps = new set<string>();
int numSequence = readInt(false);
for (int i = 0; i < numSequence; ++i)
@ -493,7 +497,7 @@ CCNode * CCBReader::readNodeGraph(CCNode * pParent) {
seqProp->setName(readCachedString()->getCString());
seqProp->setType(readInt(false));
mAnimatedProps.insert(seqProp->getName());
mAnimatedProps->insert(seqProp->getName());
int numKeyframes = readInt(false);
@ -569,6 +573,9 @@ CCNode * CCBReader::readNodeGraph(CCNode * pParent) {
}
}
#endif // CCB_ENABLE_JAVASCRIPT
delete mAnimatedProps;
mAnimatedProps = NULL;
/* Read and add children. */
int numChildren = this->readInt(false);

View File

@ -177,7 +177,7 @@ private:
CCObject *mOwner;
CCBAnimationManager *mActionManager;
std::set<std::string> mAnimatedProps;
std::set<std::string> *mAnimatedProps;
CCNodeLoaderLibrary *mCCNodeLoaderLibrary;
CCNodeLoaderListener *mCCNodeLoaderListener;
@ -214,7 +214,7 @@ public:
void setAnimationManager(CCBAnimationManager *pAnimationManager);
// Used in CCNodeLoader::parseProperties()
std::set<std::string>& getAnimatedProperties();
std::set<std::string>* getAnimatedProperties();
std::set<std::string>& getLoadedSpriteSheet();
CCObject* getOwner();

View File

@ -3,6 +3,7 @@
#include "CCBMemberVariableAssigner.h"
#include "CCBAnimationManager.h"
#include "CCData.h"
#include "CCNode+CCBRelativePositioning.h"
using namespace std;
@ -322,43 +323,10 @@ CCPoint CCNodeLoader::parsePropTypePosition(CCNode * pNode, CCNode * pParent, CC
CCSize containerSize = pCCBReader->getAnimationManager()->getContainerSize(pParent);
switch (type)
{
case kCCBPositionTypeRelativeBottomLeft:
{
/* Nothing. */
break;
}
case kCCBPositionTypeRelativeTopLeft:
{
y = containerSize.height - y;
break;
}
case kCCBPositionTypeRelativeTopRight:
{
x = containerSize.width - x;
y = containerSize.height - y;
break;
}
case kCCBPositionTypeRelativeBottomRight:
{
x = containerSize.width - x;
break;
}
case kCCBPositionTypePercent:
{
x = (int)(containerSize.width * x / 100.0f);
y = (int)(containerSize.height * y / 100.0f);
break;
}
case kCCBPositionTypeMultiplyResolution:
{
x *= CCBReader::getResolutionScale();
y *= CCBReader::getResolutionScale();
}
}
CCPoint pt = getAbsolutePosition(ccp(x,y), type, containerSize, pPropertyName);
pNode->setPosition(getAbsolutePosition(pt, type, containerSize, pPropertyName));;
if (pCCBReader->getAnimatedProperties().find(pPropertyName) != pCCBReader->getAnimatedProperties().end())
if (pCCBReader->getAnimatedProperties()->find(pPropertyName) != pCCBReader->getAnimatedProperties()->end())
{
CCArray *baseValue = CCArray::create(CCBValue::create(x),
CCBValue::create(y),
@ -367,7 +335,7 @@ CCPoint CCNodeLoader::parsePropTypePosition(CCNode * pNode, CCNode * pParent, CC
pCCBReader->getAnimationManager()->setBaseValue(baseValue, pNode, pPropertyName);
}
return CCPoint(x, y);
return pt;
}
CCPoint CCNodeLoader::parsePropTypePoint(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader)
@ -452,7 +420,7 @@ float * CCNodeLoader::parsePropTypeScaleLock(CCNode * pNode, CCNode * pParent, C
scaleLock[0] = x;
scaleLock[1] = y;
if (pCCBReader->getAnimatedProperties().find(pPropertyName) != pCCBReader->getAnimatedProperties().end())
if (pCCBReader->getAnimatedProperties()->find(pPropertyName) != pCCBReader->getAnimatedProperties()->end())
{
CCArray *baseValue = CCArray::create(CCBValue::create(x),
CCBValue::create(y),
@ -470,7 +438,7 @@ float CCNodeLoader::parsePropTypeFloat(CCNode * pNode, CCNode * pParent, CCBRead
float CCNodeLoader::parsePropTypeDegrees(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader, const char *pPropertyName) {
float ret = pCCBReader->readFloat();
if (pCCBReader->getAnimatedProperties().find(pPropertyName) != pCCBReader->getAnimatedProperties().end())
if (pCCBReader->getAnimatedProperties()->find(pPropertyName) != pCCBReader->getAnimatedProperties()->end())
{
CCBValue *value = CCBValue::create(ret);
pCCBReader->getAnimationManager()->setBaseValue(value, pNode, pPropertyName);
@ -519,7 +487,7 @@ bool CCNodeLoader::parsePropTypeCheck(CCNode * pNode, CCNode * pParent, CCBReade
{
bool ret = pCCBReader->readBool();
if (pCCBReader->getAnimatedProperties().find(pPropertyName) != pCCBReader->getAnimatedProperties().end())
if (pCCBReader->getAnimatedProperties()->find(pPropertyName) != pCCBReader->getAnimatedProperties()->end())
{
CCBValue *value = CCBValue::create(ret);
pCCBReader->getAnimationManager()->setBaseValue(value, pNode, pPropertyName);
@ -557,7 +525,7 @@ CCSpriteFrame * CCNodeLoader::parsePropTypeSpriteFrame(CCNode * pNode, CCNode *
spriteFrame = frameCache->spriteFrameByName(spriteFile->getCString());
}
if (pCCBReader->getAnimatedProperties().find(pPropertyName) != pCCBReader->getAnimatedProperties().end())
if (pCCBReader->getAnimatedProperties()->find(pPropertyName) != pCCBReader->getAnimatedProperties()->end())
{
pCCBReader->getAnimationManager()->setBaseValue(spriteFrame, pNode, pPropertyName);
}
@ -607,7 +575,7 @@ unsigned char CCNodeLoader::parsePropTypeByte(CCNode * pNode, CCNode * pParent,
{
unsigned char ret = pCCBReader->readByte();
if (pCCBReader->getAnimatedProperties().find(pPropertyName) != pCCBReader->getAnimatedProperties().end())
if (pCCBReader->getAnimatedProperties()->find(pPropertyName) != pCCBReader->getAnimatedProperties()->end())
{
pCCBReader->getAnimationManager()->setBaseValue(CCBValue::create(ret), pNode, pPropertyName);
}
@ -621,7 +589,7 @@ ccColor3B CCNodeLoader::parsePropTypeColor3(CCNode * pNode, CCNode * pParent, CC
unsigned char blue = pCCBReader->readByte();
ccColor3B color = { red, green, blue };
if (pCCBReader->getAnimatedProperties().find(pPropertyName) != pCCBReader->getAnimatedProperties().end())
if (pCCBReader->getAnimatedProperties()->find(pPropertyName) != pCCBReader->getAnimatedProperties()->end())
{
ccColor3BWapper *value = ccColor3BWapper::create(color);
pCCBReader->getAnimationManager()->setBaseValue(value, pNode, pPropertyName);