Update extensions/GUI/CCControlExtension/CCControlSwitch.cpp

implement setOn(isOn,false)
This commit is contained in:
xyhl515 2013-01-31 22:12:37 +08:00
parent 9b5d0bd251
commit 3316f8c961
1 changed files with 16 additions and 11 deletions

View File

@ -346,6 +346,7 @@ void CCControlSwitch::setOn(bool isOn, bool animated)
{ {
m_bOn = isOn; m_bOn = isOn;
if (animated) {
m_pSwitchSprite->runAction m_pSwitchSprite->runAction
( (
CCActionTween::create CCActionTween::create
@ -356,6 +357,10 @@ void CCControlSwitch::setOn(bool isOn, bool animated)
(m_bOn) ? m_pSwitchSprite->getOnPosition() : m_pSwitchSprite->getOffPosition() (m_bOn) ? m_pSwitchSprite->getOnPosition() : m_pSwitchSprite->getOffPosition()
) )
); );
}
else {
m_pSwitchSprite->setSliderXPosition((m_bOn) ? m_pSwitchSprite->getOnPosition() : m_pSwitchSprite->getOffPosition());
}
sendActionsForControlEvents(CCControlEventValueChanged); sendActionsForControlEvents(CCControlEventValueChanged);
} }