博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Cocos2d-x3.2 Progress进度条
阅读量:7019 次
发布时间:2019-06-28

本文共 1694 字,大约阅读时间需要 5 分钟。

  hot3.png

//GameScene.h#include "cocos2d.h"class GameScene : public cocos2d::Layer{public:    static cocos2d::Scene* createScene();        virtual bool init();        void menuCallback(cocos2d::Ref* pSender);        CREATE_FUNC(GameScene);};

//GameScene.cpp#include "GameScene.h"USING_NS_CC;cocos2d::Scene* GameScene::createScene(){    auto scene = Scene::create();   //创建一个场景    auto layer = GameScene::create();   //创建一个图层    scene->addChild(layer);    return scene;}//初始化当前的图层bool GameScene::init(){    if(!Layer::init())      //初始化父类        return false;        //获取屏幕大小    Size visibleSize = Director::getInstance()->getVisibleSize();    //auto size = Director::getInstance()->getWinSize();        //创建进度条    auto progress1 = ProgressTo::create(3, 100);    auto progress2 = ProgressFromTo::create(3, 50, 100);     //从30%到100%        auto progTime1 = ProgressTimer::create(Sprite::create("Icon.png"));    progTime1->setPosition(Vec2(visibleSize.width*0.4, visibleSize.height/2));    this->addChild(progTime1);        auto progTime2 = ProgressTimer::create(Sprite::create("Icon.png"));    progTime2->setPosition(Vec2(visibleSize.width*0.6, visibleSize.height/2));    this->addChild(progTime2);        //扇形    progTime1->setType(ProgressTimer::Type::RADIAL);        //3.0版本改变处    //progTime->setMidpoint(Vec2(0.25f, 0.25f));      //改变扇形中心位置    progTime1->runAction(progress1);        //条形    progTime2->setType(ProgressTimer::Type::BAR);    //progTime2->setBarChangeRate(Vec2(1, 0));      //设置进度条为横向移动,纵向移动:Vec2(0,1)    //progTime2->setMidpoint(Vec2(0, 0));        //设置进度条从左往右移动,从右往左移动:Vec2(1,0)    progTime2->runAction(progress2);            return true;}

转载于:https://my.oschina.net/Jacedy/blog/301516

你可能感兴趣的文章
刷新网卡ip
查看>>
移动构造函数和移动赋值函数
查看>>
supervisor的使用简介
查看>>
深入浅出之-route命令实战使用指南
查看>>
反掩码详解
查看>>
【Asp.Net】反射技术
查看>>
转: ㊣华哥日记㊣ 12.14-如何去了解更多的东西
查看>>
centos7中没有安装ifconfig命令的解决办法
查看>>
【资料整理】vsftpd安装配置
查看>>
Python 字符串操作方法大全
查看>>
连接远程桌面必要操作
查看>>
Python文件(夹)基本操作
查看>>
heartbeat v1(CRM)+DRBD实现数据库服务器高可用集群搭建
查看>>
-bash: snmpgetnext: command not found
查看>>
ELK+Redis日志流程展示
查看>>
python之轻松玩转微信(wechat)机器人
查看>>
D-Link光猫超管密码破解教程
查看>>
碰撞器和触发器
查看>>
cisco acs 搭建radius
查看>>
jQuery|隐藏和显示
查看>>