CCControlSwitch 开关

来源:互联网 发布:网络打码赚钱是真的吗 编辑:程序博客网 时间:2024/04/27 19:54
/*** 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);

原创粉丝点击