CCControlSlider弹窗原理跟TableView一样的,不过有点小问题,CCControlSlider的ccTouchBegan是protect的,无法被调用,于是得再包装一下
class MyCCControlSlider : public CCControlSlider
{
public:
virtual bool ccTouchBegan(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent)
{
CCControlSlider::ccTouchBegan(pTouch, pEvent);
}
virtual void ccTouchMoved(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent)
{
CCControlSlider::ccTouchMoved(pTouch, pEvent);
}
virtual void ccTouchEnded(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent)
{
CCControlSlider::ccTouchEnded(pTouch, pEvent);
}
};
因为create没有重写,因此在创建的时候
MyCCControlSlider* _slider = static_cast<MyCCControlSlider*>(CCControlSlider::create("sliderTrack.png","sliderProgress.png" ,"sliderThumb.png"));
之后再在 带屏蔽层的ccTouchXXX里面加上
_slider->ccTouch XXX就可以正常的工作了,小伙伴们赶紧试试