如何自定义 cocos2d html5 游戏-html5 Loading 界面

jQuery自定义Loading动画插件spin.js | HTML5资源教程如何自定义Cocos2d-HTML5 Loading界面_百度知道
如何自定义Cocos2d-HTML5 Loading界面
提问者采纳
&#47, 1.getInstance(),
_processLayer. &quot.L
this.c4b(255,通过长度来标示加载的进度&#47,= 100)
this.p(- this!
&#47: function () { 可以启用锚点.,后面将会说明;%& 设置当前进度条层的长度
this._processLayerLength = 500..: null.; 2 - 50))).unschedule(/
this. 这里省略,
}自定义Cocos2d-html 5 Loading界面代码,
_texture2d: null.pAdd(centerPos, -logoHeight /;;
this.init().getPercentage();base64._processL 每帧更新
_updatePercent: .; 100);&#47._processLayer._processLayer.setString(tmpStr);
&#47,}.setPosition(cc._processLayer: null..prototype.getInstance().
/&#47:&#47.._ onEnter ._super();
/&#47._processLayerLength &#47:image/ 以下方法的实现并没有跟 LoaderScene 有什么不同
return this:function(){
//&#47.extend(
_logo.Scene,/
_winSize., target) {
if (,添加了两个属性,
&#47.ignoreAnchorPointForPosition(false)._processLayer).getWinSize(); onE/ ; + percent + &quot._instance, 128),于 LoaderScene 同样
&#47., 100: _startLoading .addChild(/
var tmpStr = &quot,固做简写logoData = &quot._winSize =
/ _initStage._updatePercent)._bgLayer._instance = new Loading():&#47.changeWidth(this.
/ _logoFadeIn
/ 创建一个 Loading
this.; logo 图片和 label 的添加 .setAnchorPoint(&#47.D/&#47.&quot.
&#47,._instance) {
/ 构造函数 2;
}, 30);/Loading.create(cc,这里的编码内容挺多,
&#47.preload = function ( 这里于 LoaderScene 的实现同样L&#47..LayerC
if (percent &gt.init: null._processLayerLength * percent &#47..._label: null.S
&#47..: function () {
var percent = cc._processLayer = cc.,并设置以满足自己的需要
_logoT initWithResources .call(this); 相比 LoaderScene
的实现.,标示进度条层和进度条长度
_processLayerLLoading =&#47, 0)).p(0, 100,它就是一个红色颜色层:&#47,
_ 这里定义了 Logo 图片的 Base64 编码;data,至于为什么;/ 设置进度条层
电子产品技术支持
其他类似问题
cocos2d的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁如何自定义 Cocos2d-html5 Loading 界面_百度知道
如何自定义 Cocos2d-html5 Loading 界面
提问者采纳
&&nbsp.pAdd(centerPthis:&//&&&&&nbsp..&&&&&&&//&{&&nbsp.&nbsp.getInstance();&&;&&//&nbsp.extend(&nbsp._processL&&&&&&&=&&base64;构造函数&_startLoading&nbsp,&&+&100)&nbsp:function(){&图片的&nbsp:&nbsp._bgLLoaderScene&nbsp._processL&&&&nbsp,&&&&&&}&_bgL&nbsp,并设置以满足自己的需要&=&&nbsp.create(&&&&&&&{&nbsp.init.call(this);&nbsp.p(0;this.setPosition(cc._processL&&nbsp,它就是一个红色颜色层;&100;&&&&&&&var&nbsp.ignoreAnchorPointForPosition(false);percent&&;这里省略;&_&的实现同样Loading.&nbsp.;tmpStr&&&&logo&&&nbsp._instance&nbsp._super();编码;&&&每帧更新&this..init();return&&同样&nbsp.unschedule(&&nbsp.;&&&init..;&/&&nbsp._&&nbsp.&+&nbsp,&&};&&nbsp:image/=&&nbsp.getInstance();&nbsp自定义Cocos2d-html&&//&&//&图片和&nbsp.;&&=&Loading&&&&&&nbsp:&nbsp.&&&&nbsp.setString(tmpStr),这里的编码内容挺多;&}});&nbsp,&&&&&&&function&&nbsp.;&&&&//&&_updateP&&&1._winSize&nbsp.;(&&&nbsp._cc,&&&的添加&&//&&nbsp://&nbsp,通过长度来标示加载的进度&LoaderScene&&;&percent&&nbsp,&&nbsp,&&&&5&-&nbsp.,&function&&&&&nbsp.addChild(设置进度条层;&&nbsp.;&&有什么不同&&if&nbsp._&&&quot:&nbsp.p(-&&gt,&&&&%&&/&://&nbsp.;&这里于&nbsp.L&nbsp.S&&if&var&//&//&&nbsp!this,&&&()&()&LoaderScene&&=&nbsp.S&&function&&&nbsp,固做简写logoData&创建一个&_winS//&=&100);&&nbsp.D&&nbsp.LayerC{&&&&nbsp.preload&=&&nbsp._processLpercent&=&;&&};Loading..getWinSize()._processLayerLength&&(;&_processLayerLength.;128);onExit&&&&&&Loading界面代码;&nbsp.&&&&nbsp:&&nbsp._updatePercent);&&&&&&&这里定义了&&&&//&,&&&nbsp.;&&&&&以下方法的实现并没有跟&&=&&//&500;&nbsp:&&&&(percent&this.changeWidth(&&_processL&/&&&&nbsp.setAnchorPoint(//&//&*&nbsp:&100;30);&&&&nbsp._processLayer&可以启用锚点;设置当前进度条层的长度&2;&_logoT&&&nbsp,&&&target)&;&Loading();&&quot,至于为什么;&0));this.c4b(255.&&&&Logo&LoaderScene&onEnter&nbsp._instance)&相比&&&&nbsp,后面将会说明;//&&&&nbsp.&&_logoFadeIn&&&&nbsp.;&&nbsp.&&nbsp,&&&&_texture2d,添加了两个属性._processLayerLength&nbsp._processLayerLength&&&&nbsp:&nbsp,&50)));的实现;=&nbsp._processLayer);&&new&.&&&_initStage.getPercentage();&&nbsp,&&initWithResources&&&&nbsp,&&&&&nbsp.;//&2&&&&{&nbsp,&&,标示进度条层和进度条长度&&label&&nbsp,&nbsp,&Loading&};//&nbsp,&nbsp:&nbsp,于&Base64&&_-logoHeight&nbsp:&&&//&&nbsp,
其他类似问题
cocos2d的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁cocos2d-x关于home键黑屏跟游戏loading界面_操作系统大全_优良自学吧 |
当前位置: >
> cocos2d-x关于home键黑屏跟游戏loading界面优良自学吧提供cocos2d-x关于home键黑屏跟游戏loading界面,cocos2d-x关于home键黑屏和游戏loading界面有时候场景中的资源加载过多的话就会引起游戏进入的时候很卡,因为那是边加载边显示。还有在游戏中按下home键 再进入游戏的时候会有一段时间的黑屏,那是因为游戏要重新加载资源,这样用户体验非常不好。 我在testscocos2d-x关于home键黑屏和游戏loading界面有时候场景中的资源加载过多的话就会引起游戏进入的时候很卡,因为那是边加载边显示。还有在游戏中按下home键 再进入游戏的时候会有一段时间的黑屏,那是因为游戏要重新加载资源,这样用户体验非常不好。
我在tests例子里面发现一个很好的例子叫做TextureCacheTest,里面讲解了如何写loading。
首先在类头文件里面写上:
//loading......callback
void loadingCallBack(cocos2d::CCObject *obj);
void addSprite();
cocos2d::CCLabelTTF *m_pLabelL
cocos2d::CCLabelTTF *m_pLabelP
int m_nNumberOfS//计数用 在构造函数中初始化成要加载的资源个数
int m_nNumberOfLoadedS//初始化为0然后在cpp里面实现:这是我随便截取的代码
CCSize size = CCDirector::sharedDirector()-&getWinSize();
//////////////////////////////////////////////////////////////////////////
//loading界面
m_pLabelLoading = CCLabelTTF::create(&loading...&, &Arial&, 15);
m_pLabelPercent = CCLabelTTF::create(&%0&, &Arial&, 15);
m_pLabelLoading-&setPosition(CCPointMake(size.width / 2, size.height / 2 - 20));
m_pLabelPercent-&setPosition(CCPointMake(size.width / 2, size.height / 2 + 20));
this-&addChild(m_pLabelLoading,10);
this-&addChild(m_pLabelPercent,10);
//////////////////////////////////////////////////////////////////////////
CCTextureCache::sharedTextureCache()-&addImageAsync(&gobacknormal.png&, this, callfuncO_selector(BighurdleLayer::loadingCallBack));
CCTextureCache::sharedTextureCache()-&addImageAsync(&gobackselected.png&, this, callfuncO_selector(BighurdleLayer::loadingCallBack));
CCTextureCache::sharedTextureCache()-&addImageAsync(&Bighurdle/achievementnormal.png&, this, callfuncO_selector(BighurdleLayer::loadingCallBack));
CCTextureCache::sharedTextureCache()-&addImageAsync(&Bighurdle/achievementselected.png&, this, callfuncO_selector(BighurdleLayer::loadingCallBack));
CCTextureCache::sharedTextureCache()-&addImageAsync(&Bighurdle/Bighurdle1normal.png&, this, callfuncO_selector(BighurdleLayer::loadingCallBack));
CCTextureCache::sharedTextureCache()-&addImageAsync(&Bighurdle/Bighurdle2normal.png&, this, callfuncO_selector(BighurdleLayer::loadingCallBack));
CCTextureCache::sharedTextureCache()-&addImageAsync(&Bighurdle/Bighurdle3normal.png&, this, callfuncO_selector(BighurdleLayer::loadingCallBack));
CCTextureCache::sharedTextureCache()-&addImageAsync(&Bighurdle/Bighurdle1selected.png&, this, callfuncO_selector(BighurdleLayer::loadingCallBack));
CCTextureCache::sharedTextureCache()-&addImageAsync(&Bighurdle/Bighurdle2selected.png&, this, callfuncO_selector(BighurdleLayer::loadingCallBack));
CCTextureCache::sharedTextureCache()-&addImageAsync(&Bighurdle/Bighurdle3selected.png&, this, callfuncO_selector(BighurdleLayer::loadingCallBack));
CCTextureCache::sharedTextureCache()-&addImageAsync(&Bighurdle/Bighurdle1lock.png&, this, callfuncO_selector(BighurdleLayer::loadingCallBack));
CCTextureCache::sharedTextureCache()-&addImageAsync(&Bighurdle/Bighurdle2lock.png&, this, callfuncO_selector(BighurdleLayer::loadingCallBack));
CCTextureCache::sharedTextureCache()-&addImageAsync(&Bighurdle/Bighurdle3lock.png&, this, callfuncO_selector(BighurdleLayer::loadingCallBack));
CCTextureCache::sharedTextureCache()-&addImageAsync(&Bighurdle/Bighurdle2lockselected.png&, this, callfuncO_selector(BighurdleLayer::loadingCallBack));
CCTextureCache::sharedTextureCache()-&addImageAsync(&Bighurdle/Bighurdle3lockselected.png&, this, callfuncO_selector(BighurdleLayer::loadingCallBack));
CCTextureCache::sharedTextureCache()-&addImageAsync(&Bighurdle/main.png&, this, callfuncO_selector(BighurdleLayer::loadingCallBack));
CCTextureCache::sharedTextureCache()-&addImageAsync(&Smallhurdle/starfull.png&, this, callfuncO_selector(BighurdleLayer::loadingCallBack));然后在回调函数
void BighurdleLayer::loadingCallBack(cocos2d::CCObject *obj)
++m_nNumberOfLoadedS
char tmp[10];
sprintf(tmp,&%%%d&, (int)(((float)m_nNumberOfLoadedSprites / m_nNumberOfSprites) * 100));
m_pLabelPercent-&setString(tmp);
if (m_nNumberOfLoadedSprites == m_nNumberOfSprites)
this-&removeChild(m_pLabelLoading, true);
this-&removeChild(m_pLabelPercent, true);
addSprite();//这里是自己写得添加精灵的函数
}如果有更好的方法,请告知我,谢谢 共同进步
(本文来自互联网,不代表搜站(/)的观点和立场)编辑推荐最近更新如何自定义 Cocos2d-HTML5 Loading 界面_百度知道
如何自定义 Cocos2d-HTML5 Loading 界面
提问者采纳
能看到命名为
gamecanvas
元素.html 页面,index,在页面的 DOM 树中,加载了
cocos2d.html
开始,另一点.js,以
HelloHTML5World
为例 在开始我们的替换工作之前,值得注意的有两点、cocos2d.js 和 main:浏览器首先加载 index。从其主页面
index,在页面的最后.js
文件,大致说一下必要的(只注重我们在乎的细节问题)原有的加载流程,我们需要了解三个文件的运作方式,它将会是游戏的画布.html
其他类似问题
cocos2d的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁}

我要回帖

更多关于 cocos2d html5 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信