一开始,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. uva 11437 - Triangle Fun

    计算几何: 直线交点: #include<cstdio> using namespace std; struct node { double x,y; node(,):x(x),y(y){ ...

  2. POP3、SMTP、IMAP和Exchange的区别在哪里?

    著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处.作者:永遇乐链接:http://www.zhihu.com/question/24605584/answer/29039357来源: ...

  3. AD域环境的搭建 基于Server 2008 R2

    AD(Active Directory)即活动目录,微软的基础件.微软的很多产品如:Exchange Server,Lync Server,SharePoint Server,Forefront Se ...

  4. 利用CMake生成动态或静态链接库工程

    install解释: TARGETS版本的install命令 install(TARGETS targets... [EXPORT <export-name>] [[ARCHIVE|LIB ...

  5. Python之re模块

    参考:http://www.cnblogs.com/PythonHome/archive/2011/11/19/2255459.html 这个模块提供了与 Perl 相似l的正则表达式匹配操作.Uni ...

  6. android Theme使用三

    ☆ obtainStyledAttributes参数说明 和使用说明 1)  obtainStyledAttributes(int[]attrs) int[] attrs返回的是attrs.xml里一 ...

  7. 查找mysql数据文件存放路径

    show variables like 'datadir%'; show variables当前的会话,是系统参数 是静态 show global variables全局 show status是系统 ...

  8. Beta Round #9 (酱油杯noi考后欢乐赛)随机数生成器

    题目:http://www.contesthunter.org/contest/Beta%20Round%20%EF%BC%839%20%28%E9%85%B1%E6%B2%B9%E6%9D%AFno ...

  9. C# Protect the Password inside a TextBox ZZ

    If the Text property is called, it will send an WM_GETTEXT message, so it will surely be an internal ...

  10. Excel和XML文件导入

    using System;using System.Collections;using System.Collections.Generic;using System.Configuration;us ...