mirror of https://github.com/axmolengine/axmol.git
Merge pull request #2214 from rohankuruvilla/ccbreader
RotationX,Y for CCBuilderReader and a few bug fixes
This commit is contained in:
commit
6bcc4696e9
|
@ -286,11 +286,21 @@ CCActionInterval* CCBAnimationManager::getAction(CCBKeyframe *pKeyframe0, CCBKey
|
|||
{
|
||||
float duration = pKeyframe1->getTime() - (pKeyframe0 ? pKeyframe0->getTime() : 0);
|
||||
|
||||
if (strcmp(pPropName, "rotation") == 0)
|
||||
if (strcmp(pPropName, "rotationX") == 0)
|
||||
{
|
||||
CCBValue *value = (CCBValue*)pKeyframe1->getValue();
|
||||
return CCBRotateXTo::create(duration, value->getFloatValue());
|
||||
}
|
||||
else if(strcmp(pPropName, "rotationY") == 0)
|
||||
{
|
||||
CCBValue *value = (CCBValue*)pKeyframe1->getValue();
|
||||
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)
|
||||
{
|
||||
CCBValue *value = (CCBValue*)pKeyframe1->getValue();
|
||||
|
@ -438,6 +448,14 @@ void CCBAnimationManager::setAnimatedProperty(const char *pPropName, CCNode *pNo
|
|||
{
|
||||
float rotate = ((CCBValue*)pValue)->getFloatValue();
|
||||
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)
|
||||
{
|
||||
|
@ -912,7 +930,6 @@ void CCBSetSpriteFrame::update(float time)
|
|||
}
|
||||
|
||||
|
||||
|
||||
/************************************************************
|
||||
CCBSoundEffect
|
||||
************************************************************/
|
||||
|
@ -1035,6 +1052,161 @@ void CCBRotateTo::update(float time)
|
|||
;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/************************************************************
|
||||
CCBRotateXTO
|
||||
************************************************************/
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
//CCActionInterval::startWithTarget(pNode);
|
||||
m_pOriginalTarget = pNode;
|
||||
m_pTarget = pNode;
|
||||
m_elapsed = 0.0f;
|
||||
m_bFirstTick = true;
|
||||
mStartAngle = m_pTarget->getRotationX();
|
||||
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)
|
||||
{
|
||||
m_pTarget->setRotationX(mStartAngle + (mDiffAngle * time))
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/************************************************************
|
||||
CCBRotateYTO
|
||||
************************************************************/
|
||||
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
// CCActionInterval::startWithTarget(pNode);
|
||||
m_pOriginalTarget = pNode;
|
||||
m_pTarget = pNode;
|
||||
m_elapsed = 0.0f;
|
||||
m_bFirstTick = true;
|
||||
mStartAngle = m_pTarget->getRotationY();
|
||||
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)
|
||||
{
|
||||
m_pTarget->setRotationY(mStartAngle + (mDiffAngle * time))
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/************************************************************
|
||||
CCBEaseInstant
|
||||
************************************************************/
|
||||
|
|
|
@ -143,6 +143,7 @@ public:
|
|||
};
|
||||
|
||||
|
||||
|
||||
class CCBSoundEffect : public CCActionInstant
|
||||
{
|
||||
private:
|
||||
|
@ -174,6 +175,36 @@ public:
|
|||
virtual void startWithTarget(CCNode *pNode);
|
||||
};
|
||||
|
||||
|
||||
class CCBRotateXTo: public CCActionInterval {
|
||||
private:
|
||||
float mStartAngle;
|
||||
float mDstAngle;
|
||||
float mDiffAngle;
|
||||
public:
|
||||
static CCBRotateXTo* create(float fDuration, float fAngle);
|
||||
bool initWithDuration(float fDuration, float fAngle);
|
||||
virtual void startWithTarget(CCNode *pNode);
|
||||
virtual CCObject* copyWithZone(CCZone *pZone);
|
||||
virtual void update(float time);
|
||||
};
|
||||
|
||||
|
||||
class CCBRotateYTo: public CCActionInterval {
|
||||
private:
|
||||
float mStartAngle;
|
||||
float mDstAngle;
|
||||
float mDiffAngle;
|
||||
|
||||
public:
|
||||
static CCBRotateYTo* create(float fDuration, float fAngle);
|
||||
bool initWithDuration(float fDuration, float fAngle);
|
||||
virtual void startWithTarget(CCNode *pNode);
|
||||
virtual CCObject* copyWithZone(CCZone *pZone);
|
||||
virtual void update(float time);
|
||||
};
|
||||
|
||||
|
||||
class CCBEaseInstant : public CCActionEase
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -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) {
|
||||
if(strcmp(pPropertyName, PROPERTY_ROTATION) == 0) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ NS_CC_EXT_BEGIN
|
|||
#define PROPERTY_ANCHORPOINT "anchorPoint"
|
||||
#define PROPERTY_SCALE "scale"
|
||||
#define PROPERTY_ROTATION "rotation"
|
||||
#define PROPERTY_ROTATIONX "rotationX"
|
||||
#define PROPERTY_ROTATIONY "rotationY"
|
||||
#define PROPERTY_TAG "tag"
|
||||
#define PROPERTY_IGNOREANCHORPOINTFORPOSITION "ignoreAnchorPointForPosition"
|
||||
#define PROPERTY_VISIBLE "visible"
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
#include "AppDelegate.h"
|
||||
#include "PlayerStatus.h"
|
||||
#include "MainSceneHelper.h"
|
||||
#include "cocos2d.h"
|
||||
#include "SimpleAudioEngine.h"
|
||||
#include "ScriptingCore.h"
|
||||
#include "generated/jsb_cocos2dx_auto.hpp"
|
||||
#include "generated/jsb_cocos2dx_extension_auto.hpp"
|
||||
#include "jsb_cocos2dx_extension_manual.h"
|
||||
#include "cocos2d_specifics.hpp"
|
||||
#include "js_bindings_chipmunk_registration.h"
|
||||
#include "js_bindings_ccbreader.h"
|
||||
#include "MainSceneHelper.h"
|
||||
#include "js_bindings_system_registration.h"
|
||||
|
||||
#ifdef JSLOG
|
||||
#undef JSLOG
|
||||
|
@ -110,14 +113,18 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
|
||||
// set FPS. the default value is 1.0/60 if you don't call this
|
||||
pDirector->setAnimationInterval(1.0 / 60);
|
||||
|
||||
|
||||
ScriptingCore* sc = ScriptingCore::getInstance();
|
||||
sc->addRegisterCallback(register_all_cocos2dx);
|
||||
sc->addRegisterCallback(register_all_cocos2dx_extension);
|
||||
sc->addRegisterCallback(register_cocos2dx_js_extensions);
|
||||
sc->addRegisterCallback(register_all_cocos2dx_extension_manual);
|
||||
sc->addRegisterCallback(register_CCBuilderReader);
|
||||
sc->addRegisterCallback(jsb_register_system);
|
||||
sc->addRegisterCallback(jsb_register_chipmunk);
|
||||
|
||||
sc->start();
|
||||
|
||||
CCScriptEngineProtocol *pEngine = ScriptingCore::getInstance();
|
||||
CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
|
||||
runMainScene();
|
||||
|
|
Loading…
Reference in New Issue