CCControlSlider和CCControlStepper用法
一开始,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用法的更多相关文章
- EditText 基本用法
title: EditText 基本用法 tags: EditText,编辑框,输入框 --- EditText介绍: EditText 在开发中也是经常用到的控件,也是一个比较必要的组件,可以说它是 ...
- jquery插件的用法之cookie 插件
一.使用cookie 插件 插件官方网站下载地址:http://plugins.jquery.com/cookie/ cookie 插件的用法比较简单,直接粘贴下面代码示例: //生成一个cookie ...
- Java中的Socket的用法
Java中的Socket的用法 Java中的Socket分为普通的Socket和NioSocket. 普通Socket的用法 Java中的 ...
- [转载]C#中MessageBox.Show用法以及VB.NET中MsgBox用法
一.C#中MessageBox.Show用法 MessageBox.Show (String) 显示具有指定文本的消息框. 由 .NET Compact Framework 支持. MessageBo ...
- python enumerate 用法
A new built-in function, enumerate() , will make certain loops a bit clearer. enumerate(thing) , whe ...
- [转载]Jquery中$.get(),$.post(),$.ajax(),$.getJSON()的用法总结
本文对Jquery中$.get(),$.post(),$.ajax(),$.getJSON()的用法进行了详细的总结,需要的朋友可以参考下,希望对大家有所帮助. 详细解读Jquery各Ajax函数: ...
- 【JavaScript】innerHTML、innerText和outerHTML的用法区别
用法: <div id="test"> <span style="color:red">test1</span> tes ...
- chattr用法
[root@localhost tmp]# umask 0022 一.chattr用法 1.创建空文件attrtest,然后删除,提示无法删除,因为有隐藏文件 [root@localhost tmp] ...
- 萌新笔记——vim命令“=”、“d”、“y”的用法(结合光标移动命令,一些场合会非常方便)
vim有许多命令,网上搜有一堆贴子.文章列举出各种功能的命令. 对于"="."d"."y",我在无意中发现了它们所具有的相同的一些用法,先举 ...
随机推荐
- Network Wars
zoj2676:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1676 题意:给出一个带权无向图 ,每条边e有一个权 .求将点 ...
- perl静态编译DBD
编译DBD 项目中经常使用perl,但perl在连接数据库时,需要依赖DBI,DBD驱动,但默认安装DBD驱动时,需要依赖数据库的lib库. 比如perl连接MySQL,需要安装MySQL clien ...
- oracle热点表online rename
对于在线的繁忙业务表的任何操作都可能带来意想不到的风险.一张业务表,对partition key进行升位,其步骤是: rename原表 新建临时表 交换分区到临时表 升位临时表的字段的长度 交换临时表 ...
- MS SQL Server 如何得到执行最耗时的前N条T-SQL语句-
--得到最耗时的前N条T-SQL语句 --适用于SQL SERVER 2005及其以上版本 --给N赋初值为30 ;with maco as ( select top (@n) plan_handle ...
- SQL Server 字段状态判断语句
selct newName=case when 条件 then '否' else '是' end from tableName
- org.hibernate.LazyInitializationException: failed to lazily initialize
今天搞了一上午,都在解决这个问题:org.hibernate.LazyInitializationException: failed to lazily initialize 原因很简单,是在非法的s ...
- Android模拟器——Genymotion
还在用Android原生模拟器?向你推荐一款全方位把Android原生模拟器秒成渣渣的神器:Genymotion! 需要理由? 性能卓越作为历史上最快的Android模拟器(没有之一),秒级开机关机速 ...
- Oracle错误
System.Data.OracleClient 需要 Oracle 客户端软件 8.1.7 或更高版本 这个是我页面报的错误,请帮解答 在错误出现的时候我第一时间现在了一个oracle客户端软件,然 ...
- Android学习笔记(十一)BroadcastReceiver动态注册、注销示例
在上一篇博文中简单介绍了一下BroadcastReceiver的相关知识点,本篇举一个在代码中动态的注册.注销BroadcastReceiver的栗子. 1.首先创建一个MyReceiver并继承Br ...
- Bzoj 1609: [Usaco2008 Feb]Eating Together麻烦的聚餐 二分
1609: [Usaco2008 Feb]Eating Together麻烦的聚餐 Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 1272 Solve ...