/*
** CCControlSwitch 开关创建
** 有两种常用创建方式,一种只有前面4个参数,意义一样
** 参数1:CCSprite对象,作为掩饰底图
** 参数2:CCSprite对象,作为打开状态图
** 参数3:CCSprite对象,作为关闭状态图
** 参数4:CCSprite对象,作为拨动开关的触发图,拥有改变开关状态
** 参数5:CCLabelTTF对象,作为打开状态的文字
** 参数6:CCLabelTTF对象,作为关闭状态的文字
*/
CCControlSwitch* pSwitch = CCControlSwitch::create(
CCSprite::create("switch-mask.png"),
CCSprite::create("switch-on.png"),
CCSprite::create("switch-off.png"),
CCSprite::create("switch-thumb.png"),
CCLabelTTF::create("开","Arial-BoldMT",16),
CCLabelTTF::create("关","Arial-BoldMT",16));
pSwitch->setPosition(ccp(size.width*0.5,180));
//设置开关状态
pSwitch->setOn(false);
//设置是否可操作
pSwitch->setEnabled(true);
//获取是否打开
pSwitch->isOn();
//获取当前开关状态是否喂手动拖动开关进行的
pSwitch->hasMoved();
this->addChild(pSwitch);
CCControlSwitch 开关
最新推荐文章于 2016-07-25 20:01:12 发布