一开始,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. 机器学习的数学基础(1)--Dirichlet分布

    机器学习的数学基础(1)--Dirichlet分布 这一系列(机器学习的数学基础)主要包括目前学习过程中回过头复习的基础数学知识的总结. 基础知识:conjugate priors共轭先验 共轭先验是 ...

  2. 利用TEA算法进行数据加密

    TEA(Tiny Encryption Algorithm)是一种小型的对称加密解密算法,最初是由剑桥计算机实验室的 David Wheeler 和 Roger Needham 在 1994 年设计. ...

  3. 【HDOJ】1072 Nightmare

    bfs,使用ttl进行剪枝. #include <iostream> #include <cstdio> #include <cstring> #include & ...

  4. 【转】Android bluetooth介绍(三): 蓝牙扫描(scan)设备分析

    原文网址:http://blog.csdn.net/xubin341719/article/details/38584469 关键词:蓝牙blueZ  A2DP.SINK.sink_connect.s ...

  5. selenium-webdriver的等待方法

    Wait commands in WebDriver Listing out the different WebDriver Wait statements that can be useful fo ...

  6. python 零散记录(七)(上) 面向对象 类 类的私有化

    python面向对象的三大特性: 多态,封装,继承 多态: 在不知道对象到底是什么类型.又想对其做一些操作时,就会用到多态 如 'abc'.count('a') #对字符串使用count函数返回a的数 ...

  7. c# 如何通过反射 获取\设置属性值

    c# 如何通过反射 获取\设置属性值 //定义类public class MyClass{public int Property1 { get; set; }}static void Main(){M ...

  8. 在net安装程序中部署oracle客户端全攻略

    在net安装程序中部署oracle客户端全攻略 主要的是要做三件工作: 打包文件,写注册表,注册环境变量说明:我的oracle版本为9, 在2000 advanced server 上测试通过,可以正 ...

  9. (转)Python:self

    原文:http://www.douban.com/group/topic/19376685/ 这是对前面一个php程序员问python方法为什么要手写一个self的回答,当时那个帖非常的热闹,但是下面 ...

  10. [ZETCODE]wxWidgets教程四:菜单栏和工具栏

    本教程原文链接:http://zetcode.com/gui/wxwidgets/menustoolbars/ 翻译:瓶哥 日期:2013年11月28日星期四 邮箱:414236069@qq.com ...