cocos2d-js 进度条ccui扩展

网上关于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"],

相关文章

    本文实践自 RayWenderlich、Ali Hafizji 的文章《...
Cocos-code-ide使用入门学习地点:杭州滨江邮箱:appdevzw@1...
第一次開始用手游引擎挺激动!!!进入正题。下载资源1:从C...
    Cocos2d-x是一款强大的基于OpenGLES的跨平台游戏开发...
1.  来源 QuickV3sample项目中的2048样例游戏,以及最近《...
   Cocos2d-x3.x已经支持使用CMake来进行构建了,这里尝试...