CLoadScene类
#ifndef __LOADSCENE_H__
#define __LOADSCENE_H__ #include "GameFrameHead.h" class CGameScene; class CLoadScene : public cocos2d::CCLayer
{
public:
enum PmgressbarId
{
_PmgressbarDialog = ,
_PmgressbarPic = ,
};
public:
CLoadScene();
virtual ~CLoadScene(void);
static CCScene* create();
bool init(); public:
//加载资源
void loadRes();
//读进度回调函数
//void loadingCallBack(CCObject *obj);
protected:
void replaceMainlScene(); //场景放到这里创建
//把创建的场景加到场景管理器中
// 内部使用,外部不要调用
void initRes(); private:
CCLayer* m_pProgressLayer;
CCSprite* m_pPicLoadBG; //进度条背景 CCSprite* m_pPicBg; //界面背景图
CCProgressTimer* m_pProTimeBar; //进度条 int m_nNumberOfSprites;
int m_nNumberOfLoadedSprites;
}; #endif //__LOADSCENE_H__
#include "LoadScene.h"
#include "GameScene.h"
#include "XSprite.h"
#include "Config.h"
#include "WidgetMgr.h"
#include "SplashScene.h"
#include "XImage.h"
#include "XWidget.h"
#include "GameMainScene.h"
#include "GameConfig.h"
#include "GameLogic.h"
//#include "SplashLoading.h" #include "GameLevelScene.h" CLoadScene::CLoadScene()
{
m_pPicLoadBG = NULL;
m_pPicBg = NULL;
m_nNumberOfLoadedSprites = ;
m_nNumberOfSprites = ;
m_pProTimeBar = NULL;
} CLoadScene::~CLoadScene(void)
{
CCLOG("CLoadScene::~CLoadScene");
} CCScene* CLoadScene::create()
{ CCScene* pScene = CCScene::create();
CLoadScene* pLoadScene = new CLoadScene();
if (pScene && pLoadScene)
{
pLoadScene->init();
pScene->addChild(pLoadScene,);
pLoadScene->autorelease(); }
return pScene;
} bool CLoadScene::init()
{
//读取配置
CConfig::getInstance()->loadImageInfo();
CConfig::getInstance()->loadElementInfo();
CConfig::getInstance()->loadWidgetInfo();
CConfig::getInstance()->loadAnimationInfo();
CConfig::getInstance()->loadSrollInfo();
CConfig::getInstance()->loadEffectInfo();
CConfig::getInstance()->loadAudioInfo();
CConfig::getInstance()->loadWordInfo();
CConfig::getInstance()->loadActionInfo();
CConfig::getInstance()->loadNumberInfo(); CGameConfig::getInstance()->loadMapInfo();
CGameConfig::getInstance()->loadBiontInfo();
CGameConfig::getInstance()->loadWeaponInfo();
CGameConfig::getInstance()->loadSectInfo(); CGameLogic::getInstance()->readSaveData(); //初始化元素 把plist形式的图片资源加载到内存
vector<PlistInfo>* vecPlist = CConfig::getInstance()->getElementInfoByItem();
if (vecPlist)
{
for (vector<PlistInfo>::iterator it = vecPlist->begin(); it != vecPlist->end(); it++)
{
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(it->strPlist.c_str(), it->strImage.c_str());
}
} vector<PlistInfo>* vecPlist1 = CConfig::getInstance()->getElementInfoByItem();
if (vecPlist1)
{
for (vector<PlistInfo>::iterator it = vecPlist1->begin(); it != vecPlist1->end(); it++)
{
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(it->strPlist.c_str(), it->strImage.c_str());
}
} ////进度条界面
//CXWidget* pPmgressDlg = new CXWidget;
//CWidgetMgr::getInstance()->loadWidget(pPmgressDlg, _PmgressbarDialog);
//pPmgressDlg->autorelease();
//this->addChild(pPmgressDlg);
//
//pPmgressDlg->getCtrl(_PmgressbarPic)->setVisible(false); ////进度条
//m_pProTimeBar = CCProgressTimer::create(((CXImage*)pPmgressDlg->getCtrl(_PmgressbarPic))->getPic());
//if (m_pProTimeBar)
//{
// m_pProTimeBar->setPosition(pPmgressDlg->getCtrl(_PmgressbarPic)->getPosition());
// m_pProTimeBar->setType(kCCProgressTimerTypeBar);
// m_pProTimeBar->setMidpoint(ccp(0,0));
// m_pProTimeBar->setBarChangeRate(ccp(0.5,0));
// m_pProTimeBar->ignoreAnchorPointForPosition(true);
// //m_pProTimeBar->setAnchorPoint(ccp(0,0));
// this->addChild(m_pProTimeBar); // CCSize size = CCDirector::sharedDirector()->getWinSize();
// CCProgressTo* pProgressTo = CCProgressTo::create(2,100);
// m_pProTimeBar->runAction(pProgressTo);
//} this->loadRes();
return true;
} //void CLoadScene::loadingCallBack( CCObject *obj )
//{
// ++m_nNumberOfLoadedSprites;//每调用一次就+1
//
// //全部加载完成后,就执行
// if (m_nNumberOfLoadedSprites == m_nNumberOfSprites)
// {
// //切换场景
// //加载完 延时2秒 切换场景
// CCDelayTime* pActDelay = CCDelayTime::create(2.0f);
// CCFiniteTimeAction* pAction = CCSequence::create(pActDelay,
// CCCallFunc::create(this, callfunc_selector(CLoadScene::replaceMainlScene)),
// NULL);
// m_pProgressLayer->runAction(pAction);
// }
//
//} void CLoadScene::loadRes()
{ //把Plist文件加载到内存 CCDelayTime *delayAction = CCDelayTime::create(0.1f);
CCCallFunc *callSelectorAction = CCCallFunc::create(this,callfunc_selector(CLoadScene::replaceMainlScene));
this->runAction(CCSequence::create(delayAction, callSelectorAction, NULL)); } void CLoadScene::replaceMainlScene()
{ //CSplashLoading* pSplashLoading = CSplashLoading::create(CGameMainScene::create(CGameMainScene::_ResourceId));
//pSplashLoading->retainPrevResource();
CCDirector::sharedDirector()->replaceScene(CSplashScene::create(CGameMainScene::create(CGameMainScene::_ResourceId)));
//CCDirector::sharedDirector()->replaceScene(CSplashScene::create(CGameLevelScene::create(CGameLevelScene::_ResourceId)));
} void CLoadScene::initRes()
{
//这里初始化资源 }
CLoadScene类的更多相关文章
- Java类的继承与多态特性-入门笔记
相信对于继承和多态的概念性我就不在怎么解释啦!不管你是.Net还是Java面向对象编程都是比不缺少一堂课~~Net如此Java亦也有同样的思想成分包含其中. 继承,多态,封装是Java面向对象的3大特 ...
- C++ 可配置的类工厂
项目中常用到工厂模式,工厂模式可以把创建对象的具体细节封装到Create函数中,减少重复代码,增强可读和可维护性.传统的工厂实现如下: class Widget { public: virtual i ...
- Android请求网络共通类——Hi_博客 Android App 开发笔记
今天 ,来分享一下 ,一个博客App的开发过程,以前也没开发过这种类型App 的经验,求大神们轻点喷. 首先我们要创建一个Andriod 项目 因为要从网络请求数据所以我们先来一个请求网络的共通类. ...
- ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第二章:利用模型类创建视图、控制器和数据库
在这一章中,我们将直接进入项目,并且为产品和分类添加一些基本的模型类.我们将在Entity Framework的代码优先模式下,利用这些模型类创建一个数据库.我们还将学习如何在代码中创建数据库上下文类 ...
- ASP.NET Core 折腾笔记二:自己写个完整的Cache缓存类来支持.NET Core
背景: 1:.NET Core 已经没System.Web,也木有了HttpRuntime.Cache,因此,该空间下Cache也木有了. 2:.NET Core 有新的Memory Cache提供, ...
- .NET Core中间件的注册和管道的构建(2)---- 用UseMiddleware扩展方法注册中间件类
.NET Core中间件的注册和管道的构建(2)---- 用UseMiddleware扩展方法注册中间件类 0x00 为什么要引入扩展方法 有的中间件功能比较简单,有的则比较复杂,并且依赖其它组件.除 ...
- Java基础Map接口+Collections工具类
1.Map中我们主要讲两个接口 HashMap 与 LinkedHashMap (1)其中LinkedHashMap是有序的 怎么存怎么取出来 我们讲一下Map的增删改查功能: /* * Ma ...
- PHP-解析验证码类--学习笔记
1.开始 在 网上看到使用PHP写的ValidateCode生成验证码码类,感觉不错,特拿来分析学习一下. 2.类图 3.验证码类部分代码 3.1 定义变量 //随机因子 private $char ...
- C# 多种方式发送邮件(附帮助类)
因项目业务需要,需要做一个发送邮件功能,查了下资料,整了整,汇总如下,亲测可用- QQ邮箱发送邮件 #region 发送邮箱 try { MailMessage mail = new MailMess ...
随机推荐
- JSON数据转换成table表格
<%@ page contentType="text/html; charset=UTF-8" %> <%@taglib uri="/struts-ta ...
- 深度学习Deep learning
In the last chapter we learned that deep neural networks are often much harder to train than shallow ...
- iOS:风火轮活动刷新视图控件UIActivityIndicatorView的详细使用
动态风火轮视图控件:UIActivityIndicatorView 介绍:它是一种类似于风火轮旋转的视图控件,可用作刷新数据时显示加载过程所用,继承自UIView. 类型: typedef N ...
- Android选择/拍照 剪裁 base64/16进制/byte上传图片+PHP接收图片
转载请注明出处:http://blog.csdn.net/iwanghang/article/details/65633129认为博文实用,请点赞,请评论,请关注.谢谢! ~ 老规矩,先上GIF动态图 ...
- Nubia Z5S官方4.4 UI2.0音频Audio部分简单分析(也适用于其它8974/8064机型)以及降低破音出现几率的方法
转载请注明出处和网址链接: http://blog.csdn.net/syhost/article/details/31419749 此篇本是在Z5S的官方4.4内測版出来时写的, 主要是看到其在au ...
- 推荐大家一个CSS书写规范
CSS书写顺序 1.位置属性(position, top, right, z-index, display, float等) 2.大小(width, height, padding, margin) ...
- Unity Editor Toolbar 编辑器扩展
http://www.cnblogs.com/zhaoqingqing/p/3812368.html 1.Apply to Prefab [把改动应用到Prefab] if (GUILayout.Bu ...
- Emitting signals
Objects created from a QtCore.QObject can emit signals. In the following example we will see how we ...
- JVM-01-转载博客
JVM——Java虚拟机架构 地址:http://blog.csdn.net/seu_calvin/article/details/51404589 JVM——内存管理和垃圾回收 地址:http:// ...
- 【APP接口开发】chrome浏览器DHC工具安装使用(亲测有效)
1.DHC文件获取地址:http://chromecj.com/web-development/2015-08/549/download.html 2.chrome安装DHC插件教程和步骤:http: ...