資源簡介
此代碼是我博客的示例代碼,這個也是我自己制作的游戲引擎,當然,相當嚴重的參考了cocos代碼,所以想商用(當然并不可能有人會拿它商用)比較麻煩,得去聯系cocos
代碼片段和文件信息
#include?“Utility.h“
#include?“EngineAnimation.h“
#include?“EngineTextureCache.h“
CEngineAnimation::CEngineAnimation()
{
m_index?=?0;
m_fframeRate?=?0.0f;
m_fNextframe?=?m_fframeRate;
}
CEngineAnimation::~CEngineAnimation()
{
}
bool?CEngineAnimation::onInit(vector?vFiles)
{
for?(vector::iterator?iter?=?vFiles.begin();
iter?!=?vFiles.end();?++iter)
{
m_vframes.push_back(CEngineTextureCache::getInstance().textureForKey(*iter));
}
return?true;
}
CEngineAnimation?*?CEngineAnimation::create(vector?vFiles)
{
CEngineAnimation?*?pAnim?=?new?CEngineAnimation();
if?(pAnim&&pAnim->onInit(vFiles))
return?pAnim;
else
{
Safe_Delete(pAnim);
return?pAnim;
}
}
//循環調用
CEngineTexture2D?*?CEngineAnimation::updateframe()
{
m_fNextframe?-=?0.016f;
if?(m_fNextframe?<=?0.0f)
{
if?(m_index?==?m_vframes.size()?-?1) //當前圖片為最后一幀
m_index?=?0; //切換回第一幀
else
m_index++; //切換到下一幀
m_fNextframe?=?m_fframeRate; //重置時間
return?m_vframes.at(m_index); //根據圖片的index切換圖片
}
return?nullptr;
}
void?CEngineAnimation::setAttribute(int?_index?float?_frameRate)
{
m_index?=?_index;
m_fframeRate?=?_frameRate;
m_fNextframe?=?_frameRate;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2015-09-07?00:10??Gamefr
?????目錄???????????0??2015-09-06?23:41??Gamefr
?????目錄???????????0??2015-09-06?23:41??Gamefr
?????目錄???????????0??2015-09-06?23:41??Gamefr
?????文件???????56320??2015-09-07?00:10??Gamefr
?????目錄???????????0??2015-09-06?23:41??Gamefr
?????文件??????269824??2015-09-07?00:10??Gamefr
?????文件???????????0??2015-09-05?19:25??Gamefr
?????文件?????1263732??2015-09-07?00:10??Gamefr
?????文件?????2666496??2015-09-07?00:10??Gamefr
?????目錄???????????0??2015-09-07?00:10??Gamefr
?????文件????44302336??2015-09-07?00:10??Gamefr
?????文件?????????973??2015-09-02?11:09??Gamefr
?????文件????????1277??2015-09-02?11:09??Gamefr
?????文件?????????661??2015-09-02?11:09??Gamefr
?????文件????????1411??2015-09-02?11:09??Gamefr
?????文件?????????565??2015-09-02?11:09??Gamefr
?????文件????????2202??2015-09-06?23:52??Gamefr
?????文件?????????570??2015-09-02?11:09??Gamefr
?????文件?????????907??2015-09-06?23:55??Gamefr
?????文件?????????249??2015-09-02?11:09??Gamefr
?????文件?????????491??2015-09-02?11:09??Gamefr
?????文件?????????262??2015-09-02?11:09??Gamefr
?????文件????????2307??2015-09-02?11:09??Gamefr
?????文件????????3480??2015-09-02?11:09??Gamefr
?????文件?????????261??2015-09-02?11:09??Gamefr
?????文件?????????220??2015-09-02?11:09??Gamefr
?????文件?????????459??2015-09-02?11:09??Gamefr
?????文件?????????261??2015-09-02?11:09??Gamefr
?????文件????????3522??2015-09-02?11:09??Gamefr
?????文件????????1434??2015-09-02?11:09??Gamefr
............此處省略98個文件信息
評論
共有 條評論