加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
xcocos_utils.cpp 3.65 KB
一键复制 编辑 原始数据 按行查看 历史
passker2020 提交于 2014-08-06 10:22 . +增加建创文件
#include "xcocos_utils.h"
#include "xtransition_game_info.h"
#include <xscene_manager.h>
namespace zdh
{
//--------------------------------------------------------------------------------------
CCTransitionScene * utils::createTransition(int paramTransitionID, float paramDur, CCScene* paramDestScene)
{
switch (paramTransitionID)
{
case ETID_FADE_WHITE_TRANSITION:
return CCTransitionFade::create(paramDur, paramDestScene, ccWHITE);// XFadeWhiteTransition::create(paramDur, paramDestScene);
case ETID_FLIP_X_LEFT_OVER:
return CCTransitionFlipX::create(paramDur, paramDestScene, kCCTransitionOrientationLeftOver);
case ETID_FLIP_X_RIGHT_OVER:
return CCTransitionFlipX::create(paramDur, paramDestScene, kCCTransitionOrientationRightOver);
case ETID_FLIP_Y_UP_OVER:
return CCTransitionFlipY::create(paramDur, paramDestScene, kCCTransitionOrientationUpOver);
case ETID_FLIP_Y_DOWN_OVER:
return CCTransitionFlipY::create(paramDur, paramDestScene, kCCTransitionOrientationDownOver);
case ETID_FLIP_ANGULAR_LEFT_OVER:
return CCTransitionFlipAngular::create(paramDur, paramDestScene, kCCTransitionOrientationLeftOver);
case ETID_FLIP_ANGULAR_RIGHT_OVER:
return CCTransitionFlipAngular::create(paramDur, paramDestScene, kCCTransitionOrientationRightOver);
case ETID_CUSTOM_GAME_INFO:
return XTransitionGameInfo::create(paramDur, paramDestScene);
default:
return nullptr;
}
}
namespace utils
{
//--------------------------------------------------------------------------------------
CCSprite * createSprite(const char * paramFileName, float paramX /*= 0.0f*/, float paramY /*= 0.0f*/)
{
CCSprite * pRet = CCSprite::create(paramFileName);
pRet->setPosition(paramX, paramY);
pRet->setAnchorPoint(0, 0);
return pRet;
}
//--------------------------------------------------------------------------------------
CCSprite * createSpriteByFrameCache(const char * paramFrameName, float paramX /*= 0.0f*/, float paramY /*= 0.0f*/)
{
CCSprite * pRet = CCSprite::createWithSpriteFrameName(paramFrameName);
pRet->setPosition(paramX, paramY);
pRet->setAnchorPoint(0, 0);
return pRet;
}
//--------------------------------------------------------------------------------------
void TransitionScene(int paramTransitionID, float paramDur, int paramSceneID)
{
CCScene * pScene = SCENE_MGR->GetScene(paramSceneID);
CCTransitionScene * pTran = createTransition(paramTransitionID, paramDur, pScene);
CCDirector::sharedDirector()->replaceScene(pTran);
}
//--------------------------------------------------------------------------------------
CCAnimate * createAnimate(const char * paramFileNameFormat, XInt paramStartCode, XInt paramEndCode, float paramDur)
{
CCArray stList;
XAnsiString strTemp;
for (XInt i = paramStartCode; i <= paramEndCode; i++)
{
strTemp.printf(paramFileNameFormat, i);
CCSpriteFrame * p = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(strTemp.c_str());
stList.addObject(p);
}
CCAnimation * pAni = CCAnimation::createWithSpriteFrames(&stList, paramDur / (paramEndCode - paramStartCode + 1));
//pAni->setLoops(1);
CCAnimate * pRet = CCAnimate::create(pAni);
return pRet;
}
//--------------------------------------------------------------------------------------
void ExitGame()
{
STREAM_INFO << "OnExit";
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
CCMessageBox("You pressed the close button. Windows Store Apps do not implement a close button.", "Alert");
#else
CCDirector::sharedDirector()->end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
exit(0);
#endif
#endif
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化