mirror of https://github.com/axmolengine/axmol.git
Fixing issues with rotationX, rotationY in CCBuilderReader
This commit is contained in:
parent
54bb643ad3
commit
19b66049b3
|
@ -286,12 +286,7 @@ CCActionInterval* CCBAnimationManager::getAction(CCBKeyframe *pKeyframe0, CCBKey
|
||||||
{
|
{
|
||||||
float duration = pKeyframe1->getTime() - (pKeyframe0 ? pKeyframe0->getTime() : 0);
|
float duration = pKeyframe1->getTime() - (pKeyframe0 ? pKeyframe0->getTime() : 0);
|
||||||
|
|
||||||
if (strcmp(pPropName, "rotation") == 0)
|
if (strcmp(pPropName, "rotationX") == 0)
|
||||||
{
|
|
||||||
CCBValue *value = (CCBValue*)pKeyframe1->getValue();
|
|
||||||
return CCBRotateTo::create(duration, value->getFloatValue());
|
|
||||||
}
|
|
||||||
else if(strcmp(pPropName, "rotationX") == 0)
|
|
||||||
{
|
{
|
||||||
CCBValue *value = (CCBValue*)pKeyframe1->getValue();
|
CCBValue *value = (CCBValue*)pKeyframe1->getValue();
|
||||||
return CCBRotateXTo::create(duration, value->getFloatValue());
|
return CCBRotateXTo::create(duration, value->getFloatValue());
|
||||||
|
@ -301,6 +296,11 @@ CCActionInterval* CCBAnimationManager::getAction(CCBKeyframe *pKeyframe0, CCBKey
|
||||||
CCBValue *value = (CCBValue*)pKeyframe1->getValue();
|
CCBValue *value = (CCBValue*)pKeyframe1->getValue();
|
||||||
return CCBRotateYTo::create(duration, value->getFloatValue());
|
return CCBRotateYTo::create(duration, value->getFloatValue());
|
||||||
}
|
}
|
||||||
|
else if (strcmp(pPropName, "rotation") == 0)
|
||||||
|
{
|
||||||
|
CCBValue *value = (CCBValue*)pKeyframe1->getValue();
|
||||||
|
return CCBRotateTo::create(duration, value->getFloatValue());
|
||||||
|
}
|
||||||
else if (strcmp(pPropName, "opacity") == 0)
|
else if (strcmp(pPropName, "opacity") == 0)
|
||||||
{
|
{
|
||||||
CCBValue *value = (CCBValue*)pKeyframe1->getValue();
|
CCBValue *value = (CCBValue*)pKeyframe1->getValue();
|
||||||
|
@ -448,6 +448,14 @@ void CCBAnimationManager::setAnimatedProperty(const char *pPropName, CCNode *pNo
|
||||||
{
|
{
|
||||||
float rotate = ((CCBValue*)pValue)->getFloatValue();
|
float rotate = ((CCBValue*)pValue)->getFloatValue();
|
||||||
pNode->setRotation(rotate);
|
pNode->setRotation(rotate);
|
||||||
|
} else if(strcmp(pPropName, "rotationX") == 0)
|
||||||
|
{
|
||||||
|
float rotate = ((CCBValue*)pValue)->getFloatValue();
|
||||||
|
pNode->setRotationX(rotate);
|
||||||
|
}else if(strcmp(pPropName, "rotationY") == 0)
|
||||||
|
{
|
||||||
|
float rotate = ((CCBValue*)pValue)->getFloatValue();
|
||||||
|
pNode->setRotationY(rotate);
|
||||||
}
|
}
|
||||||
else if (strcmp(pPropName, "opacity") == 0)
|
else if (strcmp(pPropName, "opacity") == 0)
|
||||||
{
|
{
|
||||||
|
@ -1052,13 +1060,68 @@ void CCBRotateTo::update(float time)
|
||||||
************************************************************/
|
************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
CCBRotateXTo* CCBRotateXTo::create(float fDuration, float fAngle)
|
||||||
|
{
|
||||||
|
CCBRotateXTo *ret = new CCBRotateXTo();
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
if (ret->initWithDuration(fDuration, fAngle))
|
||||||
|
{
|
||||||
|
ret->autorelease();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CC_SAFE_DELETE(ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CCBRotateXTo::initWithDuration(float fDuration, float fAngle)
|
||||||
|
{
|
||||||
|
if (CCActionInterval::initWithDuration(fDuration))
|
||||||
|
{
|
||||||
|
mDstAngle = fAngle;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void CCBRotateXTo::startWithTarget(CCNode *pNode)
|
void CCBRotateXTo::startWithTarget(CCNode *pNode)
|
||||||
{
|
{
|
||||||
CCActionInterval::startWithTarget(pNode);
|
//CCActionInterval::startWithTarget(pNode);
|
||||||
mStartAngle = m_pTarget->getRotation();
|
m_pOriginalTarget = pNode;
|
||||||
|
m_pTarget = pNode;
|
||||||
|
m_elapsed = 0.0f;
|
||||||
|
m_bFirstTick = true;
|
||||||
|
mStartAngle = m_pTarget->getRotationX();
|
||||||
mDiffAngle = mDstAngle - mStartAngle;
|
mDiffAngle = mDstAngle - mStartAngle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CCObject* CCBRotateXTo::copyWithZone(CCZone *pZone)
|
||||||
|
{
|
||||||
|
CCZone *pNewZone = NULL;
|
||||||
|
CCBRotateXTo *pRet = NULL;
|
||||||
|
|
||||||
|
if (pZone && pZone->m_pCopyObject) {
|
||||||
|
pRet = (CCBRotateXTo*) (pZone->m_pCopyObject);
|
||||||
|
} else {
|
||||||
|
pRet = new CCBRotateXTo();
|
||||||
|
pZone = pNewZone = new CCZone(pRet);
|
||||||
|
}
|
||||||
|
|
||||||
|
pRet->initWithDuration(m_fDuration, mDstAngle);
|
||||||
|
CCActionInterval::copyWithZone(pZone);
|
||||||
|
CC_SAFE_DELETE(pNewZone);
|
||||||
|
return pRet;
|
||||||
|
}
|
||||||
|
|
||||||
void CCBRotateXTo::update(float time)
|
void CCBRotateXTo::update(float time)
|
||||||
{
|
{
|
||||||
m_pTarget->setRotationX(mStartAngle + (mDiffAngle * time))
|
m_pTarget->setRotationX(mStartAngle + (mDiffAngle * time))
|
||||||
|
@ -1073,13 +1136,69 @@ void CCBRotateXTo::update(float time)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CCBRotateYTo* CCBRotateYTo::create(float fDuration, float fAngle)
|
||||||
|
{
|
||||||
|
CCBRotateYTo *ret = new CCBRotateYTo();
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
if (ret->initWithDuration(fDuration, fAngle))
|
||||||
|
{
|
||||||
|
ret->autorelease();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CC_SAFE_DELETE(ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CCBRotateYTo::initWithDuration(float fDuration, float fAngle)
|
||||||
|
{
|
||||||
|
if (CCActionInterval::initWithDuration(fDuration))
|
||||||
|
{
|
||||||
|
mDstAngle = fAngle;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void CCBRotateYTo::startWithTarget(CCNode *pNode)
|
void CCBRotateYTo::startWithTarget(CCNode *pNode)
|
||||||
{
|
{
|
||||||
CCActionInterval::startWithTarget(pNode);
|
// CCActionInterval::startWithTarget(pNode);
|
||||||
mStartAngle = m_pTarget->getRotation();
|
m_pOriginalTarget = pNode;
|
||||||
|
m_pTarget = pNode;
|
||||||
|
m_elapsed = 0.0f;
|
||||||
|
m_bFirstTick = true;
|
||||||
|
mStartAngle = m_pTarget->getRotationY();
|
||||||
mDiffAngle = mDstAngle - mStartAngle;
|
mDiffAngle = mDstAngle - mStartAngle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CCObject* CCBRotateYTo::copyWithZone(CCZone *pZone)
|
||||||
|
{
|
||||||
|
CCZone *pNewZone = NULL;
|
||||||
|
CCBRotateYTo *pRet = NULL;
|
||||||
|
|
||||||
|
if (pZone && pZone->m_pCopyObject) {
|
||||||
|
pRet = (CCBRotateYTo*) (pZone->m_pCopyObject);
|
||||||
|
} else {
|
||||||
|
pRet = new CCBRotateYTo();
|
||||||
|
pZone = pNewZone = new CCZone(pRet);
|
||||||
|
}
|
||||||
|
|
||||||
|
pRet->initWithDuration(m_fDuration, mDstAngle);
|
||||||
|
CCActionInterval::copyWithZone(pZone);
|
||||||
|
CC_SAFE_DELETE(pNewZone);
|
||||||
|
return pRet;
|
||||||
|
}
|
||||||
|
|
||||||
void CCBRotateYTo::update(float time)
|
void CCBRotateYTo::update(float time)
|
||||||
{
|
{
|
||||||
m_pTarget->setRotationY(mStartAngle + (mDiffAngle * time))
|
m_pTarget->setRotationY(mStartAngle + (mDiffAngle * time))
|
||||||
|
|
|
@ -176,25 +176,31 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class CCBRotateXTo: public CCBRotateTo {
|
class CCBRotateXTo: public CCActionInterval {
|
||||||
private:
|
private:
|
||||||
float mStartAngle;
|
float mStartAngle;
|
||||||
float mDstAngle;
|
float mDstAngle;
|
||||||
float mDiffAngle;
|
float mDiffAngle;
|
||||||
public:
|
public:
|
||||||
|
static CCBRotateXTo* create(float fDuration, float fAngle);
|
||||||
|
bool initWithDuration(float fDuration, float fAngle);
|
||||||
virtual void startWithTarget(CCNode *pNode);
|
virtual void startWithTarget(CCNode *pNode);
|
||||||
|
virtual CCObject* copyWithZone(CCZone *pZone);
|
||||||
virtual void update(float time);
|
virtual void update(float time);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class CCBRotateYTo: public CCBRotateTo {
|
class CCBRotateYTo: public CCActionInterval {
|
||||||
private:
|
private:
|
||||||
float mStartAngle;
|
float mStartAngle;
|
||||||
float mDstAngle;
|
float mDstAngle;
|
||||||
float mDiffAngle;
|
float mDiffAngle;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static CCBRotateYTo* create(float fDuration, float fAngle);
|
||||||
|
bool initWithDuration(float fDuration, float fAngle);
|
||||||
virtual void startWithTarget(CCNode *pNode);
|
virtual void startWithTarget(CCNode *pNode);
|
||||||
|
virtual CCObject* copyWithZone(CCZone *pZone);
|
||||||
virtual void update(float time);
|
virtual void update(float time);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -965,7 +965,12 @@ void CCNodeLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, const
|
||||||
void CCNodeLoader::onHandlePropTypeDegrees(CCNode * pNode, CCNode * pParent, const char* pPropertyName, float pDegrees, CCBReader * pCCBReader) {
|
void CCNodeLoader::onHandlePropTypeDegrees(CCNode * pNode, CCNode * pParent, const char* pPropertyName, float pDegrees, CCBReader * pCCBReader) {
|
||||||
if(strcmp(pPropertyName, PROPERTY_ROTATION) == 0) {
|
if(strcmp(pPropertyName, PROPERTY_ROTATION) == 0) {
|
||||||
pNode->setRotation(pDegrees);
|
pNode->setRotation(pDegrees);
|
||||||
} else {
|
} else if(strcmp(pPropertyName, PROPERTY_ROTATIONX) == 0) {
|
||||||
|
pNode->setRotationX(pDegrees);
|
||||||
|
} else if(strcmp(pPropertyName, PROPERTY_ROTATIONY) == 0) {
|
||||||
|
pNode->setRotationY(pDegrees);
|
||||||
|
}
|
||||||
|
else {
|
||||||
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,8 @@ NS_CC_EXT_BEGIN
|
||||||
#define PROPERTY_ANCHORPOINT "anchorPoint"
|
#define PROPERTY_ANCHORPOINT "anchorPoint"
|
||||||
#define PROPERTY_SCALE "scale"
|
#define PROPERTY_SCALE "scale"
|
||||||
#define PROPERTY_ROTATION "rotation"
|
#define PROPERTY_ROTATION "rotation"
|
||||||
|
#define PROPERTY_ROTATIONX "rotationX"
|
||||||
|
#define PROPERTY_ROTATIONY "rotationY"
|
||||||
#define PROPERTY_TAG "tag"
|
#define PROPERTY_TAG "tag"
|
||||||
#define PROPERTY_IGNOREANCHORPOINTFORPOSITION "ignoreAnchorPointForPosition"
|
#define PROPERTY_IGNOREANCHORPOINTFORPOSITION "ignoreAnchorPointForPosition"
|
||||||
#define PROPERTY_VISIBLE "visible"
|
#define PROPERTY_VISIBLE "visible"
|
||||||
|
|
Loading…
Reference in New Issue