一开始,size的大小是系统分配。玩家可以通过setDefaultSize()更改值

1. CCControlSlider用法

CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("upgradePlist.plist");

CCLabelTTF* label = CCLabelTTF::create("8", "HelveticaNeue-Bold", 30, CCSizeMake(70,30), kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);

label->setPosition(ccp(240, 200));

label->setColor(ccc3(0, 0, 0));

this->addChild(label, 10, 603);

CCControlSlider *slider=CCControlSlider::create(CCSprite::create("progress_bg.png"), CCSprite::create("progress_bar.png"), CCSprite::createWithSpriteFrameName("pen.png"));

slider->setMinimumValue(0);

slider->setMaximumValue(100);

slider->setPosition(ccp(400,400));

addChild(slider);

slider->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::sliderValueChanged), CCControlEventValueChanged);

CCSprite *pen=slider->getThumbSprite();

pen->setAnchorPoint(ccp(0.2, 0.5));

pen->setPosition(ccp(20, pen->getContentSize().height-8));

CCControlStepper* stepper = CCControlStepper::create(CCSprite::createWithSpriteFrameName("sub_up.png"), CCSprite::createWithSpriteFrameName("add_up.png"));

stepper->setMinimumValue(1);

stepper->setMaximumValue(24);

stepper->startAutorepeat();

stepper->setValue(8);// 起始值

stepper->setStepValue(2);//步间距

((CCLabelTTF *)stepper->getPlusLabel())->setString("");

((CCLabelTTF *)stepper->getMinusLabel())->setString("");

stepper->setPosition(ccp(250, 200));

this->addChild(stepper);

stepper->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::stepperValueChange), CCControlEventValueChanged);

void HelloWorld::sliderValueChanged(CCObject* sender, CCControlEvent controlEvent){

CCControlSlider* slider = (CCControlSlider*)sender;

int theValue = slider->getValue();

CCLabelTTF * label =(CCLabelTTF * )this->getChildByTag(603);

label->setString(CCString::createWithFormat(" %d" ,theValue)->getCString());

}

void HelloWorld::stepperValueChange(CCObject* sender, CCControlEvent controlEvent){

CCControlStepper* pControl = (CCControlStepper*)sender;

int theValue = pControl->getValue();

CCLabelTTF* label = (CCLabelTTF*)this->getChildByTag(603);

label->setString(CCString::createWithFormat("%d", theValue)->getCString());

}

CCControlSlider和CCControlStepper用法的更多相关文章

  1. EditText 基本用法

    title: EditText 基本用法 tags: EditText,编辑框,输入框 --- EditText介绍: EditText 在开发中也是经常用到的控件,也是一个比较必要的组件,可以说它是 ...

  2. jquery插件的用法之cookie 插件

    一.使用cookie 插件 插件官方网站下载地址:http://plugins.jquery.com/cookie/ cookie 插件的用法比较简单,直接粘贴下面代码示例: //生成一个cookie ...

  3. Java中的Socket的用法

                                   Java中的Socket的用法 Java中的Socket分为普通的Socket和NioSocket. 普通Socket的用法 Java中的 ...

  4. [转载]C#中MessageBox.Show用法以及VB.NET中MsgBox用法

    一.C#中MessageBox.Show用法 MessageBox.Show (String) 显示具有指定文本的消息框. 由 .NET Compact Framework 支持. MessageBo ...

  5. python enumerate 用法

    A new built-in function, enumerate() , will make certain loops a bit clearer. enumerate(thing) , whe ...

  6. [转载]Jquery中$.get(),$.post(),$.ajax(),$.getJSON()的用法总结

    本文对Jquery中$.get(),$.post(),$.ajax(),$.getJSON()的用法进行了详细的总结,需要的朋友可以参考下,希望对大家有所帮助. 详细解读Jquery各Ajax函数: ...

  7. 【JavaScript】innerHTML、innerText和outerHTML的用法区别

    用法: <div id="test">   <span style="color:red">test1</span> tes ...

  8. chattr用法

    [root@localhost tmp]# umask 0022 一.chattr用法 1.创建空文件attrtest,然后删除,提示无法删除,因为有隐藏文件 [root@localhost tmp] ...

  9. 萌新笔记——vim命令“=”、“d”、“y”的用法(结合光标移动命令,一些场合会非常方便)

    vim有许多命令,网上搜有一堆贴子.文章列举出各种功能的命令. 对于"="."d"."y",我在无意中发现了它们所具有的相同的一些用法,先举 ...

随机推荐

  1. ACdream训练赛系列のJava专场

    /* * this code is made by mhy12345 * Problem: 1669 * Verdict: Accepted * Submission Date: 2015-04-21 ...

  2. spoj VFMUL FFT快速傅立叶变换模板题

    题意:求两个数相乘. 第一次写非递归的fft,因为一个数组开小了调了两天TAT. #include<iostream> #include<cstring> #include&l ...

  3. [CC150] Find a line passing the most number of points

    Problem: Given a two-dimensional graph with points on it, find a line which passes the most number o ...

  4. Spring 配置方式

    1.bean的配置方式:通过全类名(反射),通过工厂方法(静态工厂方法&实例工厂方法).FactoryBean. 2.静态工厂方法:直接调用某一个类的静态方法就可以返回bean的实例. cla ...

  5. 创建虚拟桌面的代码(重启桌面进程)(使用GetThreadDesktop,CreateDesktop,SetThreadDesktop等函数)

    在upk 里挖坟得来,有兴趣查查这几个函数... #include "windows.h" #pragma comment(lib,"user32.lib") ...

  6. eMMC(KLM8G2FE3B)

     Tiny4412原理图中,eMMC是169-PIN,资料中对应内存为16/32G:而用户手册上eMMC内存为4G,对应的是153-PIN?    原理图中上标注:KLM8G2FE3B-B001_1. ...

  7. IIS中的Application.CommonAppDataPath

    C:\ProgramData\Microsoft Corporation\Internet Information Services\7.5.7600.16385

  8. linux磁盘清理方法 Linux 下垃圾清理工具 BleachBit

    由于当初安装系统设计不合理,有些分区的过小,以及网络通讯故障等造成日志文件速度增长等其他原因都可以表现为磁盘空间满,造成无法读写磁盘,应用程序无法执行等.下面就给你支几招(以/home空间满为例): ...

  9. c#4.0新特性之协变与逆变

    1.C#3.0以前的协变与逆变 如果你是第一次听说这个两个词,别担心,他们其实很常见.C#4.0中的协变与逆变[1](Covariance and contravariance)有了进一步的完善,主要 ...

  10. NOI2003 文本编辑器editor

    1507: [NOI2003]Editor Time Limit: 5 Sec  Memory Limit: 162 MBSubmit: 1908  Solved: 738[Submit][Statu ...