cocos2d-js 进度条(ccui扩展)
发布时间:2020-12-14 16:43:03 所属栏目:百科 来源:网络整理
导读:网上关于cocos2d-js的资料有点少,都是自己研究官方的样例。。。做个记录 进度条就很常用的一个ui ccui扩展提供了一个比较方便的实现 只要设置相关参数就可以使用,跟Android的进度条差不多 代码: this._loading = new ccui.LoadingBar(); this._loading.se
网上关于cocos2d-js的资料有点少,都是自己研究官方的样例。。。做个记录
进度条就很常用的一个ui
ccui扩展提供了一个比较方便的实现
只要设置相关参数就可以使用,跟Android的进度条差不多
代码: this._loading = new ccui.LoadingBar(); this._loading.setName("LoadingBar"); this._loading.loadTexture(res.loading_1);//设置进度条的加载图片 this._loading.setPercent(30);//开始的进度 this._loading.x = screenSize.width / 2; this._loading.y = screenSize.height / 2 + this._loading.height / 4; this.addChild(this._loading); this.scheduleUpdate();//自动更新 update: function (dt) { this._count++; if (this._count > 100) { this._count = 0; } this._loading && this._loading.setPercent(this._count); } 以上大部分是官方dome给出的代码。
值得提醒的是,要是使用ccui相关扩展需要在Porject.json文件中的modules中添加 extensions模块,不然会报错的哟! "modules" : ["cocos2d","extensions"], (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |