使用cocos2d-x时遇到问题。切换菜单用于声音和音乐开关。我想让它们像苹果本地人一样可以拖拽它们。搜索网络,甚至在论坛和文档中搜索。
答案 0 :(得分:3)
我认为您正在寻找的是CCControlSwitch。
CCSprite *onSprite = CCSprite::create("ui/switch-on.png");
CCSprite *offSprite = CCSprite::create("ui/switch-off.png");
CCSprite *thumbSprite = CCSprite::create("ui/switch-thumb.png");
CCSprite *maskSprite = CCSprite::create("ui/switch-mask.png");
CCControlSwitch *control = CCControlSwitch::create(maskSprite, onSprite, offSprite, thumbSprite, nullptr, nullptr);
control->setOn(status);
control->needsLayout();
control->addTargetWithActionForControlEvents(this, cccontrol_selector(DebugLayer::toggleShowStats),, CCControlEventValueChanged);
addChild(control);
cocos2dx发行版中的samples / Cpp / TestCpp / Classes / ExtensionsTest / ControlExtensionTest中有一个示例。
希望它有所帮助, 劳伦