#ifndef __EFFECTMGR_H__#define __EFFECTMGR_H__#include "GameFrameHead.h"namespace cocos2d{ class CCFiniteTimeAction;}class GAMEFRAME_API CEffectMgr{public: enum ActionType { _Act_Sequence = 0, //顺序执行 _Act_Spawn = 1, //同时执行 }; enum Action { _CCMoveTo = 10, _CCMoveBy = 11, _CCJumpTo = 12, _CCJumpBy = 13, _CCBezierBy = 14, _CCScaleTo = 15, _CCScaleBy = 16, _CCRotateTo = 17, _CCRotateBy = 18, _CCBlink = 19, _CCTintTo = 20, _CCTintBy = 21, _CCFadeTo = 22, _CCFadeIn = 23, _CCFadeOut = 24, };public: ~CEffectMgr(); static CEffectMgr* getInstance(); static void destroy(); cocos2d::CCFiniteTimeAction* getAction(const char* psKey);private: CEffectMgr();private: static CEffectMgr* g_pEffectMgr;};#endif //__EFFECTMGR_H__
#include "EffectMgr.h"#include "Config.h"#include "XCommon.h"CEffectMgr* CEffectMgr::g_pEffectMgr = NULL;CEffectMgr::CEffectMgr(){}CEffectMgr::~CEffectMgr(){}CEffectMgr* CEffectMgr::getInstance(){ if (!g_pEffectMgr) { g_pEffectMgr = new CEffectMgr(); } return g_pEffectMgr;}void CEffectMgr::destroy(){ SAFE_DELETE(g_pEffectMgr);}cocos2d::CCFiniteTimeAction* CEffectMgr::getAction( const char* psKey ){ ActionInfo& actionInfo = *CConfig::getInstance()->getActionInfoByKey(psKey); vectorvecParam; vector vecBuf; CXCommon::split(actionInfo.strParm, string(" "), vecBuf); for (int i = 0; i < vecBuf.size(); i++) { vecParam.push_back(atof(vecBuf[i].c_str())); } CCFiniteTimeAction* pAct = NULL; switch(actionInfo.nAction) { case _CCMoveTo: { pAct = CCMoveTo::create(vecParam[0], ccp(vecParam[1], vecParam[2])); } break; case _CCMoveBy: { pAct = CCMoveBy::create(vecParam[0], ccp(vecParam[1], vecParam[2])); } break; case _CCJumpBy: { pAct = CCJumpBy::create(vecParam[0], ccp(vecParam[1], vecParam[2]), vecParam[3], vecParam[4]); } break; case _CCJumpTo: { pAct = CCJumpTo::create(vecParam[0], ccp(vecParam[1], vecParam[2]), vecParam[3], vecParam[4]); } break; case _CCBezierBy: { //暂未实现 } break; case _CCScaleTo: { pAct = CCScaleTo::create(vecParam[0], vecParam[1], vecParam[2]); } break; case _CCScaleBy: { pAct = CCScaleBy::create(vecParam[0], vecParam[1], vecParam[2]); } break; case _CCRotateTo: { pAct = CCRotateTo::create(vecParam[0], vecParam[1]); } break; case _CCBlink: { pAct = CCBlink::create(vecParam[0], vecParam[1]); } break; case _CCTintTo: { pAct = CCTintTo::create(vecParam[0], vecParam[1], vecParam[2], vecParam[3]); } break; case _CCTintBy: { pAct = CCTintBy::create(vecParam[0], vecParam[1], vecParam[2], vecParam[3]); } break; case _CCFadeTo: { pAct = CCFadeTo::create(vecParam[0], vecParam[1]); } break; case _CCFadeIn: { pAct = CCFadeIn::create(vecParam[0]); } break; case _CCFadeOut: { pAct = CCFadeOut::create(vecParam[0]); } default: { CCLog("error: action creation fails!"); } break; } ASSERT(pAct); return pAct;}