#ifndef __EFFECTMGR_H__
#define __EFFECTMGR_H__ #include "GameFrameHead.h" namespace cocos2d
{
class CCFiniteTimeAction;
} class GAMEFRAME_API CEffectMgr
{
public:
enum ActionType
{
_Act_Sequence = , //顺序执行
_Act_Spawn = , //同时执行
}; enum Action
{
_CCMoveTo = ,
_CCMoveBy = ,
_CCJumpTo = ,
_CCJumpBy = ,
_CCBezierBy = ,
_CCScaleTo = ,
_CCScaleBy = ,
_CCRotateTo = ,
_CCRotateBy = ,
_CCBlink = ,
_CCTintTo = ,
_CCTintBy = ,
_CCFadeTo = ,
_CCFadeIn = ,
_CCFadeOut = ,
}; 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);
vector<float> vecParam;
vector<string> vecBuf; CXCommon::split(actionInfo.strParm, string(" "), vecBuf);
for (int i = ; i < vecBuf.size(); i++)
{
vecParam.push_back(atof(vecBuf[i].c_str()));
} CCFiniteTimeAction* pAct = NULL;
switch(actionInfo.nAction)
{
case _CCMoveTo:
{
pAct = CCMoveTo::create(vecParam[], ccp(vecParam[], vecParam[]));
}
break;
case _CCMoveBy:
{
pAct = CCMoveBy::create(vecParam[], ccp(vecParam[], vecParam[]));
}
break;
case _CCJumpBy:
{
pAct = CCJumpBy::create(vecParam[], ccp(vecParam[], vecParam[]), vecParam[], vecParam[]);
}
break;
case _CCJumpTo:
{
pAct = CCJumpTo::create(vecParam[], ccp(vecParam[], vecParam[]), vecParam[], vecParam[]);
}
break;
case _CCBezierBy:
{
//暂未实现
}
break;
case _CCScaleTo:
{
pAct = CCScaleTo::create(vecParam[], vecParam[], vecParam[]);
}
break;
case _CCScaleBy:
{
pAct = CCScaleBy::create(vecParam[], vecParam[], vecParam[]);
}
break;
case _CCRotateTo:
{
pAct = CCRotateTo::create(vecParam[], vecParam[]);
}
break;
case _CCBlink:
{
pAct = CCBlink::create(vecParam[], vecParam[]);
}
break;
case _CCTintTo:
{
pAct = CCTintTo::create(vecParam[], vecParam[], vecParam[], vecParam[]);
}
break;
case _CCTintBy:
{
pAct = CCTintBy::create(vecParam[], vecParam[], vecParam[], vecParam[]);
}
break;
case _CCFadeTo:
{
pAct = CCFadeTo::create(vecParam[], vecParam[]);
}
break;
case _CCFadeIn:
{
pAct = CCFadeIn::create(vecParam[]);
}
break;
case _CCFadeOut:
{
pAct = CCFadeOut::create(vecParam[]);
}
default:
{
CCLog("error: action creation fails!");
}
break;
} ASSERT(pAct);
return pAct;
}
05-11 20:35